diff --git a/index.js b/index.js index 7c4649f..e271032 100644 --- a/index.js +++ b/index.js @@ -81,25 +81,8 @@ const writeShim_ = (from, to, prog, args, variables) => { shTarget = `"$basedir/${shTarget}"` } - // @SETLOCAL - // @CALL :find_dp0 - // - // @IF EXIST "%dp0%\node.exe" ( - // @SET "_prog=%dp0%\node.exe" - // ) ELSE ( - // @SET "_prog=node" - // @SET PATHEXT=%PATHEXT:;.JS;=;% - // ) - // - // "%_prog%" "%dp0%\.\node_modules\npm\bin\npm-cli.js" %* - // @ENDLOCAL - // @EXIT /b %errorlevel% - // - // :find_dp0 - // SET dp0=%~dp0 - // EXIT /b - // // Subroutine trick to fix https://github.com/npm/cmd-shim/issues/10 + // and https://github.com/npm/cli/issues/969 const head = '@ECHO off\r\n' + 'GOTO start\r\n' + ':find_dp0\r\n' + @@ -124,6 +107,9 @@ const writeShim_ = (from, to, prog, args, variables) => { + ' SET PATHEXT=%PATHEXT:;.JS;=;%\r\n' + ')\r\n' + '\r\n' + // prevent "Terminate Batch Job? (Y/n)" message + // https://github.com/npm/cli/issues/969#issuecomment-737496588 + + 'endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & ' + `"%_prog%" ${args} ${target} %*\r\n` } else { cmd = `${head}${prog} ${args} ${target} %*\r\n` diff --git a/tap-snapshots/test-basic.js-TAP.test.js b/tap-snapshots/test-basic.js-TAP.test.js index 5966bc9..df62cc8 100644 --- a/tap-snapshots/test-basic.js-TAP.test.js +++ b/tap-snapshots/test-basic.js-TAP.test.js @@ -22,7 +22,7 @@ IF EXIST "%dp0%\\node.exe" (\\r SET PATHEXT=%PATHEXT:;.JS;=;%\\r )\\r \\r -"%_prog%" "%dp0%\\from.env" %*\\r +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\\from.env" %*\\r ` @@ -94,7 +94,7 @@ IF EXIST "%dp0%\\node.exe" (\\r SET PATHEXT=%PATHEXT:;.JS;=;%\\r )\\r \\r -"%_prog%" --expose_gc "%dp0%\\from.env.args" %*\\r +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" --expose_gc "%dp0%\\from.env.args" %*\\r ` @@ -167,7 +167,7 @@ IF EXIST "%dp0%\\node.exe" (\\r SET PATHEXT=%PATHEXT:;.JS;=;%\\r )\\r \\r -"%_prog%" "%dp0%\\from.env.variables" %*\\r +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\\from.env.variables" %*\\r ` @@ -239,7 +239,7 @@ IF EXIST "%dp0%\\/usr/bin/sh.exe" (\\r SET PATHEXT=%PATHEXT:;.JS;=;%\\r )\\r \\r -"%_prog%" "%dp0%\\from.sh" %*\\r +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\\from.sh" %*\\r ` @@ -311,7 +311,7 @@ IF EXIST "%dp0%\\/usr/bin/sh.exe" (\\r SET PATHEXT=%PATHEXT:;.JS;=;%\\r )\\r \\r -"%_prog%" -x "%dp0%\\from.sh.args" %*\\r +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" -x "%dp0%\\from.sh.args" %*\\r `