This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
Relative junction should behave like dangling symlink #8813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A junction path must be absolute, which is why fs.symlink resolves paths on Windows if the type is
junction
. E.g.fs.symlink("../foo", "my/link", "junction")
. From the docs:Sidenote: Reading that, you'd think the
dstpath
argument is normalized. What the docs mean to say is that thesrcpath
(the target) is normalized. The function signature in the source isfs.symlink(destination, path)
; these inconsistencies are confusing.However, the target seems to be normalized relative to the working directory - not relative to the link's parent directory like it should:
Of course, a junction is not the same as a symlink, but the behavior should be consistent, given that node on unix ignores the
junction
argument and will create a dangling symlink. It should do the same on Windows, or at least simulate it. This PR normalizes the target, relative to the link's parent directory. Meaning:fs.symlink("..\foo", "C:\my\link", "junction")
becomes:
fs.symlink("C:\foo", "C:\my\link", "junction")
The included test is copied from
test-fs-symlink-dir-junction.js
. These tests could probably be merged, I didn't (yet) for the sake of clarity - and because the other (regular symlink) tests fail anyway on Windows XP.