Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix #2465: Make npm script and windows shims cygwin-aware

  • Loading branch information...
commit c2daa506da847c5c161121410e2780cad789ff8b 1 parent 173091b
@pkhpkh pkhpkh authored isaacs committed
Showing with 34 additions and 9 deletions.
  1. +10 −3 bin/npm
  2. +24 −6 lib/utils/cmd-shim.js
View
13 bin/npm
@@ -1,6 +1,13 @@
#!/bin/sh
-if [ -x "`dirname "$0"`/node.exe" ]; then
- "`dirname "$0"`/node.exe" "`dirname "$0"`/node_modules/npm/bin/npm-cli.js" "$@"
+
+basedir=`dirname "$0"`
+
+case `uname` in
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+esac
+
+if [ -x "$basedir/node.exe" ]; then
+ "$basedir/node.exe" "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
else
- node "`dirname "$0"`/node_modules/npm/bin/npm-cli.js" "$@"
+ node "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
fi
View
30 lib/utils/cmd-shim.js
@@ -67,15 +67,15 @@ function writeShim_ (from, to, prog, args, cb) {
args = args || ""
if (!prog) {
prog = "\"%~dp0\\" + target + "\""
- shProg = "\"`dirname \"$0\"`/" + shTarget + "\""
+ shProg = "\"$basedir/" + shTarget + "\""
args = ""
target = ""
shTarget = ""
} else {
longProg = "\"%~dp0\\" + prog + ".exe\""
- shLongProg = "\"`dirname \"$0\"`/" + prog + "\""
+ shLongProg = "\"$basedir/" + prog + "\""
target = "\"%~dp0\\" + target + "\""
- shTarget = "\"`dirname \"$0\"`/" + shTarget + "\""
+ shTarget = "\"$basedir/" + shTarget + "\""
}
// @IF EXIST "%~dp0\node.exe" (
@@ -97,15 +97,33 @@ function writeShim_ (from, to, prog, args, cb) {
cmd = ":: Created by npm, please don't edit manually.\r\n" + cmd
// #!/bin/sh
- // if [ -x "`dirname "$0"`/node.exe" ]; then
- // "`dirname "$0"`/node.exe" "`dirname "$0"`/node_modules/npm/bin/npm-cli.js" "$@"
+ // basedir=`dirname "$0"`
+ //
+ // case `uname` in
+ // *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+ // esac
+ //
+ // if [ -x "$basedir/node.exe" ]; then
+ // "$basedir/node.exe" "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
+ // ret=$?
// else
- // node "`dirname "$0"`/node_modules/npm/bin/npm-cli.js" "$@"
+ // node "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
+ // ret=$?
// fi
+ // exit $ret
+
var sh = "#!/bin/sh\n"
if (shLongProg) {
sh = sh
+ + "basedir=`dirname \"$0\"`\n"
+ + "\n"
+ + "case `uname` in\n"
+ + " *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;\n"
+ + "esac\n"
+ + "\n"
+
+ sh = sh
+ "if [ -x "+shLongProg+" ]; then\n"
+ " " + shLongProg + " " + args + " " + shTarget + " \"$@\"\n"
+ " ret=$?\n"
Please sign in to comment.
Something went wrong with that request. Please try again.