From 3d91d2fe768256a2e045e4c5fb0235a37ddefa4f Mon Sep 17 00:00:00 2001 From: Jason Yi Date: Sat, 10 Jan 2026 18:10:04 +1100 Subject: [PATCH 1/3] Remove redundant -r Node flags --- overrides/path/node | 4 ++-- overrides/path/node.bat | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/overrides/path/node b/overrides/path/node index ee1061ca..6c243754 100755 --- a/overrides/path/node +++ b/overrides/path/node @@ -38,7 +38,7 @@ PREPEND_PATH="$SCRIPT_DIR/../js/prepend-node.js" # Call node with the given arguments, prefixed with our extra logic if command -v winpty >/dev/null 2>&1; then - winpty "$real_node" -r "$PREPEND_PATH" "$@" + winpty "$real_node" "$@" else - "$real_node" -r "$PREPEND_PATH" "$@" + "$real_node" "$@" fi \ No newline at end of file diff --git a/overrides/path/node.bat b/overrides/path/node.bat index 54f32247..093a0c5a 100755 --- a/overrides/path/node.bat +++ b/overrides/path/node.bat @@ -13,4 +13,4 @@ REM Reset PATH, so its visible to node & subprocesses set PATH=%ORIGINALPATH% REM Start Node for real, with an extra arg to inject our logic -"%REAL_NODE%" -r "%WRAPPER_FOLDER%\..\js\prepend-node.js" %* \ No newline at end of file +"%REAL_NODE%" %* \ No newline at end of file From 5c551b6e4fb907f1cb30234cbe6870f601243021 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Tue, 20 Jan 2026 17:24:37 +0100 Subject: [PATCH 2/3] Don't use --require in node override if NODE_OPTIONS is set correctly --- overrides/path/node | 24 ++++++++++++++++++------ overrides/path/node.bat | 16 +++++++++++++--- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/overrides/path/node b/overrides/path/node index 6c243754..a19c5c18 100755 --- a/overrides/path/node +++ b/overrides/path/node @@ -36,9 +36,21 @@ PATH="$SCRIPT_DIR:$PATH" # Define the path to our helper script using the reliable SCRIPT_DIR PREPEND_PATH="$SCRIPT_DIR/../js/prepend-node.js" -# Call node with the given arguments, prefixed with our extra logic -if command -v winpty >/dev/null 2>&1; then - winpty "$real_node" "$@" -else - "$real_node" "$@" -fi \ No newline at end of file +case "$NODE_OPTIONS" in + *"$HTTP_TOOLKIT_OVERRIDE_PATH"*) + # If our config is already inside NODE_OPTIONS, we don't need to do anything: + if command -v winpty >/dev/null 2>&1; then + winpty "$real_node" "$@" + else + "$real_node" "$@" + fi + ;; + *) + # Otherwise, we need to inject --require $PREPEND into the node CLI: + if command -v winpty >/dev/null 2>&1; then + winpty "$real_node" --require "$PREPEND_PATH" "$@" + else + "$real_node" --require "$PREPEND_PATH" "$@" + fi + ;; +esac \ No newline at end of file diff --git a/overrides/path/node.bat b/overrides/path/node.bat index 093a0c5a..ad7d6748 100755 --- a/overrides/path/node.bat +++ b/overrides/path/node.bat @@ -7,10 +7,20 @@ set WRAPPER_FOLDER=%HTTP_TOOLKIT_OVERRIDE_PATH%\path call set PATH=%%PATH:%WRAPPER_FOLDER%;=%% REM Get the real node path, store it in %REAL_NODE% -FOR /F "tokens=*" %%g IN ('where node') do (SET REAL_NODE=%%g) +FOR /F "tokens=*" %%g IN ('where node') do ( + SET REAL_NODE=%%g + GOTO :Break +) +:Break REM Reset PATH, so its visible to node & subprocesses set PATH=%ORIGINALPATH% -REM Start Node for real, with an extra arg to inject our logic -"%REAL_NODE%" %* \ No newline at end of file +REM Check if our config is already inside NODE_OPTIONS, if so then we don't actually +REM need to do anything: +echo "%NODE_OPTIONS%" | findstr /C:"%HTTP_TOOLKIT_OVERRIDE_PATH%" >nul 2>&1 +if %errorlevel% equ 0 ( + "%REAL_NODE%" %* +) else ( + "%REAL_NODE%" --require "%WRAPPER_FOLDER%\..\js\prepend-node.js" %* +) \ No newline at end of file From 74b428ea18bd0718479cad761561bf04d2e9e26b Mon Sep 17 00:00:00 2001 From: Jason Yi Date: Wed, 21 Jan 2026 10:07:30 +1100 Subject: [PATCH 3/3] Check for forward-slash path instead in NODE_OPTIONS for windows --- overrides/path/node.bat | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/overrides/path/node.bat b/overrides/path/node.bat index ad7d6748..c3d6ac26 100755 --- a/overrides/path/node.bat +++ b/overrides/path/node.bat @@ -17,8 +17,11 @@ REM Reset PATH, so its visible to node & subprocesses set PATH=%ORIGINALPATH% REM Check if our config is already inside NODE_OPTIONS, if so then we don't actually -REM need to do anything: -echo "%NODE_OPTIONS%" | findstr /C:"%HTTP_TOOLKIT_OVERRIDE_PATH%" >nul 2>&1 +REM need to do anything. +REM NODE_OPTIONS includes forward slash paths even on Windows for some reason, so +REM check for that instead. +set "OVERRIDE_PATH_POSIX=%HTTP_TOOLKIT_OVERRIDE_PATH:\=/%" +echo "%NODE_OPTIONS%" | findstr /C:"%OVERRIDE_PATH_POSIX%" >nul 2>&1 if %errorlevel% equ 0 ( "%REAL_NODE%" %* ) else (