+15
-2
lines changedFilter options
+15
-2
lines changed Original file line number Diff line number Diff line change
@@ -196,7 +196,9 @@ function onLink(destStat, src, dest, verbatimSymlinks) {
196
196
if (!isAbsolute(resolvedDest)) {
197
197
resolvedDest = resolve(dirname(dest), resolvedDest);
198
198
}
199
-
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
199
+
const srcIsDir = fsBinding.internalModuleStat(src) === 1;
200
+
201
+
if (srcIsDir && isSrcSubdir(resolvedSrc, resolvedDest)) {
200
202
throw new ERR_FS_CP_EINVAL({
201
203
message: `cannot copy ${resolvedSrc} to a subdirectory of self ` +
202
204
`${resolvedDest}`,
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ const {
15
15
writeFileSync,
16
16
} = fs;
17
17
import net from 'net';
18
-
import { join } from 'path';
18
+
import { join, resolve } from 'path';
19
19
import { pathToFileURL } from 'url';
20
20
import { setTimeout } from 'timers/promises';
21
21
@@ -248,6 +248,17 @@ function nextdir(dirname) {
248
248
);
249
249
}
250
250
251
+
// It allows copying when is not a directory
252
+
{
253
+
const src = nextdir();
254
+
const dest = nextdir();
255
+
mkdirSync(src, mustNotMutateObjectDeep({ recursive: true }));
256
+
writeFileSync(`${src}/test.txt`, 'test');
257
+
symlinkSync(resolve(`${src}/test.txt`), join(src, 'link.txt'));
258
+
cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true }));
259
+
cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true }));
260
+
}
261
+
251
262
// It throws error if symlink in dest points to location in src.
252
263
{
253
264
const src = nextdir();
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4