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

fix: don't assume cygpath is available #117

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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