Skip to content

Commit 166ae8b

Browse files
committed
Ensure node/php inherit the correct PATH for their subprocesses
1 parent 98cdbed commit 166ae8b

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

overrides/path/node

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
# Exclude ourselves from PATH within this script, to avoid recursing
5-
PATH="${PATH/`dirname $0`:/}"
4+
# Exclude ourselves from PATH, find the real node, then reset PATH
5+
PATH="${PATH//`dirname $0`:/}"
6+
real_node=`command -v node`
7+
PATH="`dirname $0`:$PATH"
68

7-
GLOBAL_AGENT_PATH=`dirname $0`/prepend.js
9+
PREPEND_PATH=`dirname $0`/prepend.js
810

911
# Call node with the given arguments, prefixed with our extra logic
1012
if command -v winpty >/dev/null 2>&1; then
11-
winpty node -r "$GLOBAL_AGENT_PATH" "$@"
13+
winpty $real_node -r "$PREPEND_PATH" "$@"
1214
else
13-
node -r "$GLOBAL_AGENT_PATH" "$@"
15+
$real_node -r "$PREPEND_PATH" "$@"
1416
fi

overrides/path/php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
# Exclude ourselves from PATH within this script, to avoid recursing
5-
PATH="${PATH/`dirname $0`:/}"
4+
# Exclude ourselves from PATH, find the real php, then reset PATH
5+
PATH="${PATH//`dirname $0`:/}"
6+
real_php=`command -v php`
7+
PATH="`dirname $0`:$PATH"
68

79
# Call PHP with the given arguments, and a few extra
810
PHP_ARGS=(
@@ -17,7 +19,7 @@ PHP_ARGS=(
1719
)
1820

1921
if command -v winpty >/dev/null 2>&1; then
20-
winpty php ${PHP_ARGS[@]}
22+
winpty $real_php ${PHP_ARGS[@]}
2123
else
22-
php ${PHP_ARGS[@]}
24+
$real_php ${PHP_ARGS[@]}
2325
fi

0 commit comments

Comments
 (0)