Skip to content

Commit

Permalink
fix errors thrown if symlink source does not exist (yarnpkg#2744)
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Kosikhin authored and bestander committed Feb 27, 2017
1 parent f8fd813 commit b409e18
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/util/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,12 @@ export async function symlink(src: string, dest: string): Promise<void> {
await fsSymlink(src, dest, 'junction');
} else {
// use relative paths otherwise which will be retained if the directory is moved
const relative = path.relative(fs.realpathSync(path.dirname(dest)), fs.realpathSync(src));
let relative;
if (await exists(src)) {
relative = path.relative(fs.realpathSync(path.dirname(dest)), fs.realpathSync(src));
} else {
relative = path.relative(path.dirname(dest), src);
}
await fsSymlink(relative, dest);
}
} catch (err) {
Expand Down

0 comments on commit b409e18

Please sign in to comment.