1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #!/usr/bin/env bash
- (set -o igncr) 2>/dev/null && set -o igncr;
- basedir=`dirname "$0"`
- case `uname` in
- *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
- esac
- if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then
- IS_WSL="true"
- fi
- function no_node_dir {
-
- echo "Could not determine Node.js install directory" >&2
- exit 1
- }
- NODE_EXE="$basedir/node.exe"
- if ! [ -x "$NODE_EXE" ]; then
- NODE_EXE="$basedir/node"
- fi
- if ! [ -x "$NODE_EXE" ]; then
- NODE_EXE=node
- fi
- CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"
- if [ $? -ne 0 ]; then
-
-
-
- if [ "$IS_WSL" == "true" ]; then
- echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&2
- fi
- no_node_dir
- fi
- NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"
- NPX_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npx-cli.js"
- NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`
- if [ $? -ne 0 ]; then
- no_node_dir
- fi
- NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"
- NPX_WSL_PATH="/.."
- if [ "$IS_WSL" == "true" ]; then
- NPX_WSL_PATH=`wslpath "$NPM_PREFIX_NPX_CLI_JS"`
- fi
- if [ -f "$NPM_PREFIX_NPX_CLI_JS" ] || [ -f "$NPX_WSL_PATH" ]; then
- NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS"
- fi
- "$NODE_EXE" "$NPX_CLI_JS" "$@"
|