Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fs): add copy/copySync #278

Merged
merged 30 commits into from
May 16, 2019
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
449a219
feat: add copy/copySync for fs modules
axetroy Mar 14, 2019
2aa835c
fix: eslint error
axetroy Mar 14, 2019
57af76b
use unimplemented() instead of throw by it self
axetroy Mar 16, 2019
a5231ca
fix: import without ext
axetroy Mar 17, 2019
76bdda3
Merge branch 'master' of https://github.com/denoland/deno_std into copy
axetroy Mar 17, 2019
a06d75e
refactor
axetroy Mar 17, 2019
67acf47
WIP: try to add copyLink
axetroy Mar 18, 2019
5a0b8ad
Merge branch 'master' into copy
axetroy May 13, 2019
b99d5a3
Merge branch 'copy' of https://github.com/axetroy/deno_std into copy
axetroy May 13, 2019
f79991b
fix eslint error
axetroy May 13, 2019
7c9aefc
rename function name
axetroy May 14, 2019
f670a8a
refactor add add preserve timestamps support
axetroy May 15, 2019
6c72aba
Merge branch 'master' into copy
axetroy May 15, 2019
4f6dcb4
fix eslint
axetroy May 15, 2019
fd5aebe
fix eslint
axetroy May 15, 2019
d626976
export copy() for mod.ts
axetroy May 15, 2019
37b6f4b
completed test case
axetroy May 15, 2019
98827b5
fix test in windows
axetroy May 15, 2019
347d755
update test case
axetroy May 15, 2019
ac690d6
try fix in windows
axetroy May 15, 2019
fff9a2d
try fix windows
axetroy May 15, 2019
7d4b1b8
update fs readme
axetroy May 15, 2019
86f723c
format readme
axetroy May 15, 2019
be2737d
update test case. do not modify the origin test folder
axetroy May 16, 2019
26c46f1
wrap 80 col for comments
axetroy May 16, 2019
41e05c0
fix grammar error
axetroy May 16, 2019
184aba4
refactor test case.
axetroy May 16, 2019
ca3c417
update test case
axetroy May 16, 2019
4b71be5
improve error message
axetroy May 16, 2019
94034cb
fix eslint
axetroy May 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename function name
  • Loading branch information
axetroy committed May 14, 2019
commit 7c9aefc7260d45c693b7c3c2513bed17b729243a
16 changes: 8 additions & 8 deletions fs/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ function copyFileSync(src: string, dest: string): void {
Deno.copyFileSync(src, dest);
}

/* copy link to dest */
async function copyLink(src: string, dest: string): Promise<void> {
/* copy symlink to dest */
async function copySymLink(src: string, dest: string): Promise<void> {
const originSrcFilePath = await Deno.readlink(src);
const type = getFileInfoType(await Deno.lstat(src));
await Deno.symlink(originSrcFilePath, dest, type);
}

/* copy link to dest synchronously */
function copyLinkSync(src: string, dest: string): void {
/* copy symlink to dest synchronously */
function copySymlinkSync(src: string, dest: string): void {
const originSrcFilePath = Deno.readlinkSync(src);
const type = getFileInfoType(Deno.lstatSync(src));
Deno.symlinkSync(originSrcFilePath, dest, type);
Expand All @@ -45,7 +45,7 @@ async function copyDir(src: string, dest: string): Promise<void> {
} else if (file.isFile()) {
await copyFile(srcPath, destPath);
} else if (file.isSymlink()) {
await copyLink(srcPath, destPath);
await copySymLink(srcPath, destPath);
}
}
}
Expand All @@ -62,7 +62,7 @@ function copyDirSync(src: string, dest: string): void {
} else if (file.isFile()) {
copyFileSync(srcPath, destPath);
} else if (file.isSymlink()) {
copyLinkSync(srcPath, destPath);
copySymlinkSync(srcPath, destPath);
}
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ export async function copy(
if (destStat) {
await destOverwriteCheck();
}
await copyLink(src, dest);
await copySymLink(src, dest);
}
}

Expand Down Expand Up @@ -201,6 +201,6 @@ export function copySync(
if (destStat) {
destOverwriteCheck();
}
copyLinkSync(src, dest);
copySymlinkSync(src, dest);
}
}