diff options
author | João Reis <reis@janeasystems.com> | 2015-07-28 18:43:58 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-08-21 04:58:23 +0300 |
commit | 89320ba9d27e25ea3f8c88d7089d9fcf0bf0d440 (patch) | |
tree | a45dd8ef69774cd07df099786a0ae35b2bc2c210 /bin/npm.cmd | |
parent | 599240faeb22e2529302e877e620b43b8b6d83b4 (diff) |
windows: search for a user-installed npm
This changes npm.cmd and the npm script when running in Cygwin to look
for an npm installation in prefix, running it if found. The default npm
is used to get the prefix. This implements the changes described in
https://github.com/joyent/node/issues/8528 .
Fixes joyent/node#8528. Reference: joyent/node#8554.
Fixes: #6412
PR-URL: https://github.com/npm/npm/pull/9089
Diffstat (limited to 'bin/npm.cmd')
-rw-r--r-- | bin/npm.cmd | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/npm.cmd b/bin/npm.cmd index 7720e2052..f111c59d1 100644 --- a/bin/npm.cmd +++ b/bin/npm.cmd @@ -1,6 +1,19 @@ :: Created by npm, please don't edit manually.
-@IF EXIST "%~dp0\node.exe" (
- "%~dp0\node.exe" "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*
-) ELSE (
- node "%~dp0\.\node_modules\npm\bin\npm-cli.js" %*
+@ECHO OFF
+
+SETLOCAL
+
+SET "NODE_EXE=%~dp0\node.exe"
+IF NOT EXIST "%NODE_EXE%" (
+ SET "NODE_EXE=node"
)
+
+SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
+FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
+ SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
+)
+IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
+ SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
+)
+
+"%NODE_EXE%" "%NPM_CLI_JS%" %*
|