Skip to content

fix: follow cwd symlink on windows #410

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mukaschultze
Copy link

Node's process.cwd() has different behaviour between unix OS's and Windows when the cwd is inside a symlink. This PR fixes this inconsistency by calling node's fs.realpathSync to follow the directory symlink and simulate unix's behaviour on Windows.

This incosistency causes patch-package to fail on Windows when it runs on a postinstall of a workspace package since yarn (and possibly other package managers as well) use symlinks to hoist packages to the root node_modules.

This PR also fixes the path comparison on the getAppRootPath, since Windows can have both \ and / path separators.

@edusperoni
Copy link

You might want to use .replace(sep, "/") (sep comes from path and will replace whatever the separator is on that filesystem to /)

@milahu
Copy link
Contributor

milahu commented Oct 24, 2022

milahu#21 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants