-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Expand file tree
/
Copy pathtest-fs-cp-sync-dereference.js
More file actions
39 lines (30 loc) · 945 Bytes
/
test-fs-cp-sync-dereference.js
File metadata and controls
39 lines (30 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
// Refs: https://github.com/nodejs/node/issues/58939
//
// The cpSync function is not correctly handling the `dereference` option.
// In this test, both the cp and cpSync functions are attempting to copy
// a file over a symlinked directory. In the cp case it works fine. In the
// cpSync case it fails with an error.
const common = require('../common');
const {
cp,
cpSync,
mkdirSync,
symlinkSync,
writeFileSync,
} = require('fs');
const {
join,
} = require('path');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const pathA = join(tmpdir.path, 'a');
const pathB = join(tmpdir.path, 'b');
const pathC = join(tmpdir.path, 'c');
const pathD = join(tmpdir.path, 'd');
writeFileSync(pathA, 'file a');
mkdirSync(pathB);
symlinkSync(pathB, pathC, 'dir');
symlinkSync(pathB, pathD, 'dir');
cp(pathA, pathD, { dereference: false }, common.mustSucceed());
cpSync(pathA, pathC, { dereference: false });