Skip to content
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

Windows: Add preliminary WSL support for npm and npx #253

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bin/npm
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix

basedir=`dirname "$0"`
isexe=0

case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

NODE_EXE="$basedir/node.exe"
if [ -x "$NODE_EXE" ]; then
isexe=1
fi
if ! [ -x "$NODE_EXE" ]; then
infinnie marked this conversation as resolved.
Show resolved Hide resolved
NODE_EXE="$basedir/node"
fi
Expand All @@ -34,4 +38,9 @@ case `uname` in
;;
esac

if [ isexe==1 ] && [ -f "/bin/wslpath" ]; then # run the corresponding command prompt when Node for Windows is executed within WSL
cmd.exe /c `wslpath -w "$basedir/npm.cmd"` "$@"
return
infinnie marked this conversation as resolved.
Show resolved Hide resolved
fi

"$NODE_EXE" "$NPM_CLI_JS" "$@"
9 changes: 9 additions & 0 deletions bin/npx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix

basedir=`dirname "$0"`
isexe=0

case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

NODE_EXE="$basedir/node.exe"
if [ -x "$NODE_EXE" ]; then
isexe=1
fi
if ! [ -x "$NODE_EXE" ]; then
NODE_EXE=node
fi
Expand All @@ -32,4 +36,9 @@ case `uname` in
;;
esac

if [ isexe==1 ] && [ -f "/bin/wslpath" ]; then # run the corresponding cmd instead
infinnie marked this conversation as resolved.
Show resolved Hide resolved
cmd.exe /c `wslpath -w "$basedir/npx.cmd"` "$@"
return
fi

"$NODE_EXE" "$NPX_CLI_JS" "$@"