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: follow cwd symlink on windows #21

Merged
merged 2 commits into from
Oct 24, 2022
Merged

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.

@milahu
Copy link
Owner

milahu commented Oct 24, 2022

thanks! this looks harmless and useful ; )

upstream is using the old version

https://github.com/ds300/patch-package/blob/86ed9f675c418d658544b49037932dd5200852d2/src/getAppRootPath.ts#L6

  let cwd = process.cwd()

fixed replace

"aaa".replace("a", "b")
// 'baa'

"aaa".replace(/a/g, "b")
// 'bbb'

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

Successfully merging this pull request may close these issues.

2 participants