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: resolve real path for case insensitive systems #4935
fix: resolve real path for case insensitive systems #4935
Conversation
💖 Thanks for opening this pull request! 💖 |
|
||
async function getRealPath (path: string) { | ||
return new Promise<string>((resolve) => { | ||
fs.realpath.native(path, function (err, resolvedPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shoud fs.realpath.native
be used instead of fs.realpath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs.realpath.native
return the actual casing of a path as it is on disk https://github.com/nodejs/node/pull/15776/files#diff-05bc37150ff4e7aa51dc7a28c71164a9e715f45e323ac9a5c67e061821aad3d2R8, fs.realpath
is resolving ..
, .
and sym links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case it is better to add a comment about it because in the Node.js docs this information is not present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zkochan I've added comments on getRealPath
@zkochan I fixed test for case-sensitive system. I skipped them, because it is not possible to open the path |
e58ccd4
to
c5e930e
Compare
Run |
Congrats on merging your first pull request! 🎉🎉🎉 |
For case insensitive systems (Windows)
findWorkspaceDir
will return the path to the module as it was called (because ofcwd
) not the real path.It leads to an issue when
getImporters
can't find the the manifest (#4904).Can be reproduces if
pnpm
was called from "c:\code\project" but the real path is "C:\Code\Project".getImporters
will find allmanifestsByPath
as "C:\Code\Project...", butprefixes
will use workspace root "c:\code\project...", and it can't match them.It is possible to try true-case-path but has some vulnerable deps.