Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Local node incorrectly resolved on Windows #41

Open
connorjsmith opened this issue Sep 29, 2019 · 0 comments
Open

Local node incorrectly resolved on Windows #41

connorjsmith opened this issue Sep 29, 2019 · 0 comments

Comments

@connorjsmith
Copy link

Disclaimer: I am not that experienced with cmd scripting

After updating to the latest npm, some of our scripts broke. I traced this to the change in #26, which always quotes the executable name (even if it is just node). This seems to cause issues for some paths (The system cannot find the path specified.)

Proposed fix (using tslint as an example):

@ECHO off
SETLOCAL
CALL :find_dp0

SET _maybeQuote="
IF EXIST "%dp0%\node.exe" (
  SET "_prog=%dp0%\node.exe"
) ELSE (
  SET "_prog=node"
  SET _maybeQuote=
  SET PATHEXT=%PATHEXT:;.JS;=;%
)

%_maybeQuote%%_prog%%_maybeQuote%  "%dp0%\..\tslint\bin\tslint" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

For the %dp0% case, this resolves to
"%dp0%\node.exe" "%dp0%\..\tslint\bin\tslint" %*
otherwise, it resolves to
node "%dp0%\..\tslint\bin\tslint" %*

Effectively, we only use quotes around the node executable when we use .bin\node.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant