Skip to content

Commit

Permalink
fix(windows) yarnpkg#5349 node and yarn can't be launch on Windows in…
Browse files Browse the repository at this point in the history
…to mingw64

As npm workaround, launch node.exe

See also https://github.com/npm/cli/blob/bd2721dbc3de13a5ba889eba50644475d80f6948/bin/npm
  • Loading branch information
JulioJu committed Sep 24, 2020
1 parent cbeead6 commit 69f1fed
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions bin/yarn
Expand Up @@ -2,18 +2,23 @@
argv0=$(echo "$0" | sed -e 's,\\,/,g')
basedir=$(dirname "$(readlink "$0" || echo "$argv0")")

is_mingw64_or_cygwin=0

case "$(uname -s)" in
Darwin) basedir="$( cd "$( dirname "$argv0" )" && pwd )";;
Linux) basedir=$(dirname "$(readlink -f "$0" || echo "$argv0")");;
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
*MSYS*) basedir=`cygpath -w "$basedir"`;;
*CYGWIN*) basedir=`cygpath -w "$basedir"` ; is_mingw64_or_cygwin=1 ;;
*MSYS*) basedir=`cygpath -w "$basedir"` ; is_mingw64_or_cygwin=1 ;;
esac

command_exists() {
command -v "$1" >/dev/null 2>&1;
}

if command_exists node; then
if [ "$YARN_FORCE_WINPTY" != 1 ] && [ "$is_mingw64_or_cygwin" = 1 ] && command_exists "node.exe" ; then
exec node.exe "$basedir/yarn.js" "$@"
ret=$?
elif command_exists node; then
if [ "$YARN_FORCE_WINPTY" = 1 ] || command_exists winpty && test -t 1; then
winpty node "$basedir/yarn.js" "$@"
else
Expand Down

0 comments on commit 69f1fed

Please sign in to comment.