File tree Expand file tree Collapse file tree 2 files changed +34
-9
lines changed
Expand file tree Collapse file tree 2 files changed +34
-9
lines changed Original file line number Diff line number Diff line change @@ -36,9 +36,21 @@ PATH="$SCRIPT_DIR:$PATH"
3636# Define the path to our helper script using the reliable SCRIPT_DIR
3737PREPEND_PATH=" $SCRIPT_DIR /../js/prepend-node.js"
3838
39- # Call node with the given arguments, prefixed with our extra logic
40- if command -v winpty > /dev/null 2>&1 ; then
41- winpty " $real_node " -r " $PREPEND_PATH " " $@ "
42- else
43- " $real_node " -r " $PREPEND_PATH " " $@ "
44- fi
39+ case " $NODE_OPTIONS " in
40+ * " $HTTP_TOOLKIT_OVERRIDE_PATH " * )
41+ # If our config is already inside NODE_OPTIONS, we don't need to do anything:
42+ if command -v winpty > /dev/null 2>&1 ; then
43+ winpty " $real_node " " $@ "
44+ else
45+ " $real_node " " $@ "
46+ fi
47+ ;;
48+ * )
49+ # Otherwise, we need to inject --require $PREPEND into the node CLI:
50+ if command -v winpty > /dev/null 2>&1 ; then
51+ winpty " $real_node " --require " $PREPEND_PATH " " $@ "
52+ else
53+ " $real_node " --require " $PREPEND_PATH " " $@ "
54+ fi
55+ ;;
56+ esac
Original file line number Diff line number Diff line change @@ -7,10 +7,23 @@ set WRAPPER_FOLDER=%HTTP_TOOLKIT_OVERRIDE_PATH%\path
77call set PATH = %% PATH:%WRAPPER_FOLDER% ;=%%
88
99REM Get the real node path, store it in %REAL_NODE%
10- FOR /F " tokens=*" %%g IN ('where node') do (SET REAL_NODE=%%g )
10+ FOR /F " tokens=*" %%g IN ('where node') do (
11+ SET REAL_NODE = %%g
12+ GOTO :Break
13+ )
14+ :Break
1115
1216REM Reset PATH, so its visible to node & subprocesses
1317set PATH = %ORIGINALPATH%
1418
15- REM Start Node for real, with an extra arg to inject our logic
16- " %REAL_NODE% " -r " %WRAPPER_FOLDER% \..\js\prepend-node.js" %*
19+ REM Check if our config is already inside NODE_OPTIONS, if so then we don't actually
20+ REM need to do anything.
21+ REM NODE_OPTIONS includes forward slash paths even on Windows for some reason, so
22+ REM check for that instead.
23+ set " OVERRIDE_PATH_POSIX = %HTTP_TOOLKIT_OVERRIDE_PATH:\ =/ % "
24+ echo " %NODE_OPTIONS% " | findstr /C:" %OVERRIDE_PATH_POSIX% " > nul 2 >& 1
25+ if %errorlevel% equ 0 (
26+ " %REAL_NODE% " %*
27+ ) else (
28+ " %REAL_NODE% " --require " %WRAPPER_FOLDER% \..\js\prepend-node.js" %*
29+ )
You can’t perform that action at this time.
0 commit comments