Skip to content

Commit 5080b0d

Browse files
committed
Add Windows support to Node.js CLI interception
1 parent ccfabb0 commit 5080b0d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

overrides/path/node.bat

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@echo off
2+
SETLOCAL
3+
4+
REM Exclude ourselves from PATH within this script, to avoid recursing
5+
set ORIGINALPATH=%PATH%
6+
REM Get the current file's folder
7+
set THIS_PATH=%~dp0
8+
REM Strip the trailing slash from the folder
9+
set WRAPPER_FOLDER=%THIS_PATH:~0,-1%
10+
REM Remove that folder from PATH
11+
call set PATH=%%PATH:%WRAPPER_FOLDER%;=%%
12+
13+
REM Get the real node path, store it in %REAL_NODE%
14+
FOR /F "tokens=*" %%g IN ('where node') do (SET REAL_NODE=%%g)
15+
16+
REM Reset PATH, so its visible to node & subprocesses
17+
set PATH=%ORIGINALPATH%
18+
19+
REM Start Node for real, with an extra arg to inject our logic
20+
"%REAL_NODE%" -r "%WRAPPER_FOLDER%\prepend.js" %*

0 commit comments

Comments
 (0)