Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] Reports invalid process.cwd() #69

Open
1 task done
jclab-joseph opened this issue Jun 22, 2022 · 0 comments
Open
1 task done

[BUG] Reports invalid process.cwd() #69

jclab-joseph opened this issue Jun 22, 2022 · 0 comments
Labels
Needs Triage needs an initial review

Comments

@jclab-joseph
Copy link

jclab-joseph commented Jun 22, 2022

Is there an existing issue for this?

  • I have searched the existing issues

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% & '

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Needs Triage needs an initial review
Projects
None yet
Development

No branches or pull requests

1 participant