patch-package icon indicating copy to clipboard operation
patch-package copied to clipboard

fix: follow cwd symlink on windows

Open mukaschultze opened this issue 2 years ago • 2 comments

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.

mukaschultze avatar Aug 05 '22 20:08 mukaschultze

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

edusperoni avatar Aug 18 '22 13:08 edusperoni

https://github.com/milahu/patch-package/pull/21#issuecomment-1288918158

milahu avatar Oct 24 '22 17:10 milahu