Skip to content

Commit

Permalink
Prevent "Terminate Batch Job? (Y/n)" prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Feb 5, 2021
1 parent 98176d0 commit c039646
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
22 changes: 4 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' +
Expand All @@ -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`
Expand Down
10 changes: 5 additions & 5 deletions tap-snapshots/test-basic.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
`

Expand Down Expand Up @@ -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
`

Expand Down Expand Up @@ -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
`

Expand Down Expand Up @@ -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
`

Expand Down Expand Up @@ -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
`

Expand Down

0 comments on commit c039646

Please sign in to comment.