Skip to content

Commit

Permalink
fix: don't assume cygpath is available (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
davhdavh authored Oct 18, 2023
1 parent 3ef7197 commit 3bdb518
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 12 deletions.
12 changes: 10 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ const writeShim_ = (from, to, prog, args, variables) => {
// basedir=`dirname "$0"`
//
// case `uname` in
// *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
// *CYGWIN*|*MINGW*|*MSYS*)
// if command -v cygpath > /dev/null 2>&1; then
// basedir=`cygpath -w "$basedir"`
// fi
// ;;
// esac
//
// if [ -x "$basedir/node.exe" ]; then
Expand All @@ -137,7 +141,11 @@ const writeShim_ = (from, to, prog, args, variables) => {
+ `basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")\n`
+ '\n'
+ 'case `uname` in\n'
+ ' *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;\n'
+ ' *CYGWIN*|*MINGW*|*MSYS*)\n'
+ ' if command -v cygpath > /dev/null 2>&1; then\n'
+ ' basedir=`cygpath -w "$basedir"`\n'
+ ' fi\n'
+ ' ;;\n'
+ 'esac\n'
+ '\n'

Expand Down
60 changes: 50 additions & 10 deletions tap-snapshots/test/basic.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ exports[`test/basic.js TAP env shebang > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
if [ -x "$basedir/node" ]; then
Expand Down Expand Up @@ -132,7 +136,11 @@ exports[`test/basic.js TAP env shebang with args > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
if [ -x "$basedir/node" ]; then
Expand Down Expand Up @@ -202,7 +210,11 @@ exports[`test/basic.js TAP env shebang with variables > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
if [ -x "$basedir/node" ]; then
Expand Down Expand Up @@ -271,7 +283,11 @@ exports[`test/basic.js TAP explicit shebang > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
if [ -x "$basedir//usr/bin/sh" ]; then
Expand Down Expand Up @@ -340,7 +356,11 @@ exports[`test/basic.js TAP explicit shebang with args > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
if [ -x "$basedir//usr/bin/sh" ]; then
Expand Down Expand Up @@ -389,7 +409,11 @@ exports[`test/basic.js TAP if exists (it does exist) > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
exec "$basedir/from.exe" "$@"
Expand Down Expand Up @@ -434,7 +458,11 @@ exports[`test/basic.js TAP just proceed if reading fails > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
exec "$basedir/" "$@"
Expand Down Expand Up @@ -501,7 +529,11 @@ exports[`test/basic.js TAP multiple variables > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
if [ -x "$basedir/node" ]; then
Expand Down Expand Up @@ -550,7 +582,11 @@ exports[`test/basic.js TAP no shebang > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
exec "$basedir/from.exe" "$@"
Expand Down Expand Up @@ -615,7 +651,11 @@ exports[`test/basic.js TAP shebang with env -S > shell 1`] = `
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
case \`uname\` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=\`cygpath -w "$basedir"\`;;
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=\`cygpath -w "$basedir"\`
fi
;;
esac
if [ -x "$basedir/node" ]; then
Expand Down

0 comments on commit 3bdb518

Please sign in to comment.