mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
fs: fix cp handle existing symlinks
PR-URL: https://github.com/nodejs/node/pull/58476 Fixes: https://github.com/nodejs/node/issues/58468 Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com>
This commit is contained in:
1 parent
d2931e50e3
commit
996fdb05ab
2 files changed
+23
-2
No files matched your search
@@ -248,7 +248,7 @@ function nextdir(dirname) {
|
||||
);
|
||||
}
|
||||
|
||||
// It allows copying when is not a directory
|
||||
// It allows cpSync copying symlinks in src to locations in dest with existing synlinks not pointing to a directory.
|
||||
{
|
||||
const src = nextdir();
|
||||
const dest = nextdir();
|
||||
@@ -259,6 +259,23 @@ function nextdir(dirname) {
|
||||
cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true }));
|
||||
}
|
||||
|
||||
// It allows cp copying symlinks in src to locations in dest with existing synlinks not pointing to a directory.
|
||||
{
|
||||
const src = nextdir();
|
||||
const dest = nextdir();
|
||||
mkdirSync(src, mustNotMutateObjectDeep({ recursive: true }));
|
||||
writeFileSync(`${src}/test.txt`, 'test');
|
||||
symlinkSync(resolve(`${src}/test.txt`), join(src, 'link.txt'));
|
||||
cp(src, dest, { recursive: true },
|
||||
mustCall((err) => {
|
||||
assert.strictEqual(err, null);
|
||||
|
||||
cp(src, dest, { recursive: true }, mustCall((err) => {
|
||||
assert.strictEqual(err, null);
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
||||
// It throws error if symlink in dest points to location in src.
|
||||
{
|
||||
const src = nextdir();
|
||||
|
||||
Reference in new issue
Block a user