-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support Windows and npm link install scenario #1
Conversation
Hey @ayan4m1, thanks for your interest in the package. Let me go over your changes to better understand it. In the same time, I've found that it's easier and seems to be more stable to just use cli "interface" for npm (similar way how it's done for yarn) rather than trying to keep up with internal changes. This is how I'd like to do it in this package as well: Please review that part to see if it matches your use case and how it would affect your changes in this PR. Thank you. |
…e executioner to start npm, log npm/yarn output after execution
Thank you for the quick feedback! I have hopefully addressed everything you pointed out.
It is worth noting that with Yarn, the console.log output is being hidden or lost due to yarnpkg/yarn#5476 - no idea what's going on there but it threw me for a loop at first. Theoretically this code will work if and when the yarn behavior changes. Re-tested on Windows Node 10, Linux Node 6 and 10, yarn and npm - all scenarios result in peer dependencies correctly installed. |
Thanks a lot for the changes. I'll add your as a contributor, so you can merge when it's all clear. Thank you. |
Happy to help, thanks for being so responsive. I am also |
Perfect. Thank you. Added you on npm:
|
I would like to use this package to help manage the pain point of installing
react-dom
manually. This package would seem to be the perfect solution. However, I found (after several hours investigation) that it does not seem to support Windows, because the matcher regex used to find npm and/or yarn only matches on Unix-style paths.In testing/reproducing this, I also found that it does not work when used as an
npm link
package - because__dirname
used ininstall.js
points to the physical path on disk of the non-symlinked package directory, not the path thatinstall-peers
occupies under thenode_modules
of the package (e.g./code/install-peers
rather than/code/install-peers-test/node_modules/install-peers
which is a symlink to/code/install-peers
).I am using these configurations to test peer dependency installation.
Example output using 1.0.2 on Windows (
react-dom
is not present innode_modules
afterward):Example output using my branch on Windows (
react-dom
is present innode_modules
afterward):I have prepared this pull request with four changes:
install-yarn.js
andinstall-npm.js
that "flips" the path separators if the platform is win32, allowing the regex matcher to work on WindowsrootPath
will be set toprocess.env.INIT_CWD
if it is present (npm 5+), which allows the package to be used innpm link
scenarios on *nix - this environment variable avoids the need to use relative pathing to find the package root__dirname
toprocess.cwd()
inrootPath
fallback initialization, which allows the package to be used innpm link
scenariosconsole.error
message if neitheryarn
nornpm
are found on the system, thus alerting the user to the reason no action was taken during executionThere is one case, where the user is on *nix and does not have npm 5+, where the
npm link
scenario will fail. However, this has always been the case. Unfortunately,process.cwd()
process.env.PWD
and__dirname
are all the "incorrect" value in this environment, andprocess.env.INIT_CWD
is not available.My testing on Windows was done using Windows 10, Node 10.12.0. I regression-tested the package using it in both
npm link
and non-link scenarios on CentOS 7, Node 6.14.4 (npm 3) and 10.13.0 (npm 6).Please let me know your thoughts and feedback.