Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Ensure valid target passed to fs.symlink (refs #3276) #3946

Merged
merged 1 commit into from Jul 19, 2017
Merged

Fix: Ensure valid target passed to fs.symlink (refs #3276) #3946

merged 1 commit into from Jul 19, 2017

Conversation

ghost
Copy link

@ghost ghost commented Jul 18, 2017

Summary
path.relative returns an empty string for the current directory. This was being passed as the target to fs.symlink. Changed it so '.' is passed instead in these cases. Fixes issue #3276.

Test plan
The fix is very small and straightforward so haven't added a test. Can do if needed.

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

src/util/fs.js Outdated
} else {
relative = path.relative(path.dirname(dest), src);
relative = path.relative(path.dirname(dest), src) || '.';
}
await fsSymlink(relative, dest);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do await fsSymlink(relative || '.', dest); instead?

Also please add a comment above why we default to '.' (basically, the summary of this PR as a comment :))

@BYK BYK changed the title Bugfix 3276: Ensuring valid target passed to fs.symlink Fix: Ensure valid target passed to fs.symlink (refs #3276) Jul 18, 2017
`path.relative` returns an empty string for the current directory. This
was being passed as the target to `fs.symlink`. Changed it so '.' is
passed instead in these cases.
@ghost
Copy link
Author

ghost commented Jul 18, 2017

Changes made 👍

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@BYK BYK merged commit 8409de5 into yarnpkg:master Jul 19, 2017
@BYK BYK added this to Done in Yarn 1.0 Jul 19, 2017
@ghost ghost deleted the symlink-bug branch July 21, 2017 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants