Skip to content

Commit 6a2b4bc

Browse files
fixup! fs: add support for mode flag to specify the copy behavior
1 parent 52038c0 commit 6a2b4bc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

doc/api/fs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ changes:
997997
exists. Use the `errorOnExist` option to change this behavior.
998998
**Default:** `true`.
999999
* `mode` {integer} modifiers for copy operation. **Default:** `0`.
1000-
See `mode` flag of [`fsPromises.copyFile()`][]
1000+
See `mode` flag of [`fsPromises.copyFile()`][].
10011001
* `preserveTimestamps` {boolean} When `true` timestamps from `src` will
10021002
be preserved. **Default:** `false`.
10031003
* `recursive` {boolean} copy directories recursively **Default:** `false`
@@ -2328,7 +2328,7 @@ changes:
23282328
exists. Use the `errorOnExist` option to change this behavior.
23292329
**Default:** `true`.
23302330
* `mode` {integer} modifiers for copy operation. **Default:** `0`.
2331-
See `mode` flag of [`fs.copyFile()`][]
2331+
See `mode` flag of [`fs.copyFile()`][].
23322332
* `preserveTimestamps` {boolean} When `true` timestamps from `src` will
23332333
be preserved. **Default:** `false`.
23342334
* `recursive` {boolean} copy directories recursively **Default:** `false`
@@ -5233,7 +5233,7 @@ changes:
52335233
exists. Use the `errorOnExist` option to change this behavior.
52345234
**Default:** `true`.
52355235
* `mode` {integer} modifiers for copy operation. **Default:** `0`.
5236-
See `mode` flag of [`fs.copyFileSync()`][]
5236+
See `mode` flag of [`fs.copyFileSync()`][].
52375237
* `preserveTimestamps` {boolean} When `true` timestamps from `src` will
52385238
be preserved. **Default:** `false`.
52395239
* `recursive` {boolean} copy directories recursively **Default:** `false`

test/parallel/test-fs-cp.mjs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -877,29 +877,32 @@ if (!isWindows) {
877877

878878
// It copies a nested folder structure with mode flags.
879879
// This test is based on fs.promises.copyFile() with `COPYFILE_FICLONE_FORCE`.
880-
await (async () => {
880+
{
881881
const src = './test/fixtures/copy/kitchen-sink';
882882
const dest = nextdir();
883883
let p = null;
884+
let successFiClone = false;
884885
try {
885886
p = await fs.promises.cp(src, dest, mustNotMutateObjectDeep({
886887
recursive: true,
887888
mode: fs.constants.COPYFILE_FICLONE_FORCE,
888889
}));
890+
successFiClone = true;
889891
} catch (err) {
890892
// If the platform does not support `COPYFILE_FICLONE_FORCE` operation,
891893
// it should enter this path.
892894
assert.strictEqual(err.syscall, 'copyfile');
893895
assert(err.code === 'ENOTSUP' || err.code === 'ENOTTY' ||
894896
err.code === 'ENOSYS' || err.code === 'EXDEV');
895-
return;
896897
}
897898

898-
// If the platform support `COPYFILE_FICLONE_FORCE` operation,
899-
// it should reach to here.
900-
assert.strictEqual(p, undefined);
901-
assertDirEquivalent(src, dest);
902-
})();
899+
if (successFiClone) {
900+
// If the platform support `COPYFILE_FICLONE_FORCE` operation,
901+
// it should reach to here.
902+
assert.strictEqual(p, undefined);
903+
assertDirEquivalent(src, dest);
904+
}
905+
}
903906

904907
// It accepts file URL as src and dest.
905908
{

0 commit comments

Comments
 (0)