Skip to content

Commit

Permalink
fix: preserve exit code in .cmd files
Browse files Browse the repository at this point in the history
Because we're now exiting with an explicit exit command, we have to
preserve %errorlevel% (the equivalent of $? in bash).
  • Loading branch information
isaacs committed Aug 21, 2019
1 parent c380c2a commit 2debda0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function writeShim_ (from, to, prog, args, variables, cb) {
//
// "%_prog%" "%dp0%\.\node_modules\npm\bin\npm-cli.js" %*
// @ENDLOCAL
// @EXIT /b
// @EXIT /b %errorlevel%
//
// :find_dp0
// SET dp0=%~dp0
Expand All @@ -124,7 +124,7 @@ function writeShim_ (from, to, prog, args, variables, cb) {
'SETLOCAL\r\n' +
'CALL :find_dp0\r\n'
var foot = 'ENDLOCAL\r\n' +
'EXIT /b\r\n' +
'EXIT /b %errorlevel%\r\n' +
':find_dp0\r\n' +
'SET dp0=%~dp0\r\n' +
'EXIT /b\r\n'
Expand Down
16 changes: 8 additions & 8 deletions tap-snapshots/test-basic.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ IF EXIST "%dp0%\\node.exe" (\\r
\\r
"%_prog%" "%dp0%\\from.env" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down Expand Up @@ -81,7 +81,7 @@ IF EXIST "%dp0%\\node.exe" (\\r
\\r
"%_prog%" --expose_gc "%dp0%\\from.env.args" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down Expand Up @@ -144,7 +144,7 @@ IF EXIST "%dp0%\\node.exe" (\\r
\\r
"%_prog%" "%dp0%\\from.env.variables" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down Expand Up @@ -206,7 +206,7 @@ IF EXIST "%dp0%\\/usr/bin/sh.exe" (\\r
\\r
"%_prog%" "%dp0%\\from.sh" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down Expand Up @@ -268,7 +268,7 @@ IF EXIST "%dp0%\\/usr/bin/sh.exe" (\\r
\\r
"%_prog%" -x "%dp0%\\from.sh.args" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down Expand Up @@ -322,7 +322,7 @@ SETLOCAL\\r
CALL :find_dp0\\r
"%dp0%\\from.exe" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down Expand Up @@ -363,7 +363,7 @@ SETLOCAL\\r
CALL :find_dp0\\r
"%dp0%\\" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down Expand Up @@ -404,7 +404,7 @@ SETLOCAL\\r
CALL :find_dp0\\r
"%dp0%\\from.exe" %*\\r
ENDLOCAL\\r
EXIT /b\\r
EXIT /b %errorlevel%\\r
:find_dp0\\r
SET dp0=%~dp0\\r
EXIT /b\\r
Expand Down

0 comments on commit 2debda0

Please sign in to comment.