patch-package
patch-package copied to clipboard
fix: follow cwd symlink on windows
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.
You might want to use .replace(sep, "/")
(sep comes from path and will replace whatever the separator is on that filesystem to /)
https://github.com/milahu/patch-package/pull/21#issuecomment-1288918158