diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2017-07-09 01:20:33 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2017-07-11 03:09:54 +0300 |
commit | fb040bee0710759c60e45bf8fa2a3b8ddcf4212a (patch) | |
tree | fbd20b9c0b119495436404b8effa5a417269e80c /bin/npx | |
parent | 88aafee8b5b232b7eeb5690279a098d056575791 (diff) |
npx: bundle npx with npm itself
npx is an npm package runner with a bunch of nice features. While
it is also available on the npm registry as `npx`, it's the sort
of thing that's better off being bundles with npm itself.
Fixes: #6053
PR-URL: https://github.com/npm/npm/pull/17685
Credit: @zkat
Reviewed-By: @iarna
Diffstat (limited to 'bin/npx')
-rw-r--r-- | bin/npx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/npx b/bin/npx new file mode 100644 index 000000000..a49c608ba --- /dev/null +++ b/bin/npx @@ -0,0 +1,34 @@ +#!/bin/sh +(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix + +basedir=`dirname "$0"` + +case `uname` in + *CYGWIN*) basedir=`cygpath -w "$basedir"`;; +esac + +NODE_EXE="$basedir/node.exe" +if ! [ -x "$NODE_EXE" ]; then + NODE_EXE=node +fi + +NPX_CLI_JS="$basedir/node_modules/npm/bin/npx-cli.js" + +case `uname` in + *MINGW*) + NPM_PREFIX=`"$NODE_EXE" "$NPX_CLI_JS" prefix -g` + NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js" + if [ -f "$NPM_PREFIX_NPX_CLI_JS" ]; then + NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS" + fi + ;; + *CYGWIN*) + NPM_PREFIX=`"$NODE_EXE" "$NPX_CLI_JS" prefix -g` + NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js" + if [ -f "$NPM_PREFIX_NPX_CLI_JS" ]; then + NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS" + fi + ;; +esac + +"$NODE_EXE" "$NPX_CLI_JS" "$@" |