Skip to content

Commit e4344a4

Browse files
Petr Kosikhinbestander
Petr Kosikhin
authored andcommitted
fix errors thrown if symlink source does not exist (#2744)
1 parent 495900a commit e4344a4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/util/fs.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,12 @@ export async function symlink(src: string, dest: string): Promise<void> {
419419
await fsSymlink(src, dest, 'junction');
420420
} else {
421421
// use relative paths otherwise which will be retained if the directory is moved
422-
const relative = path.relative(fs.realpathSync(path.dirname(dest)), fs.realpathSync(src));
422+
let relative;
423+
if (await exists(src)) {
424+
relative = path.relative(fs.realpathSync(path.dirname(dest)), fs.realpathSync(src));
425+
} else {
426+
relative = path.relative(path.dirname(dest), src);
427+
}
423428
await fsSymlink(relative, dest);
424429
}
425430
} catch (err) {

0 commit comments

Comments
 (0)