Is there an existing issue for this?
Current Behavior
The working directory changed by cd after setlocal is not maintained.
So process.cwd() returns the wrong location.
Expected Behavior
The current directory after the cd command should be kept.
Steps To Reproduce
$HOME\AppData\Roaming\npm\aaaa.js :
console.log('CWD:', process.cwd());
$HOME\AppData\Roaming\npm\test.cmd :
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\aaaa.js" %*
test.bat:
setlocal
cd C:\abcdefg\
test.cmd
endlocal
Run test.bat
CWD: C:\Users...\ (Other directory instead of "C:\abcdefg")
Environment
- npm: 8.12.2
- Node: v16.15.1
- OS: Windows
- platform:
Source
|
+ 'endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & ' |
Is there an existing issue for this?
Current Behavior
The working directory changed by cd after setlocal is not maintained.
So process.cwd() returns the wrong location.
Expected Behavior
The current directory after the
cdcommand should be kept.Steps To Reproduce
$HOME\AppData\Roaming\npm\aaaa.js :
$HOME\AppData\Roaming\npm\test.cmd :
test.bat:
Run test.bat
Environment
Source
cmd-shim/lib/index.js
Line 113 in 4660668