@@ -12,9 +12,11 @@ REAL_SCRIPT_DIR="$(dirname "$REAL_SCRIPT_PATH")"
1212BOOSTER_ROOT=" $( cd " $REAL_SCRIPT_DIR /../.." && pwd) "
1313
1414# If running via symlink (PROJECT_ROOT != BOOSTER_ROOT), add booster dependencies to PATH
15+ RELATIVE_BOOSTER_PATH=" "
1516if [ " $PROJECT_ROOT " != " $BOOSTER_ROOT " ]; then
1617 export PATH=" $BOOSTER_ROOT /node_modules/.bin:$BOOSTER_ROOT /vendor/bin:$PATH "
1718 export NODE_PATH=" $BOOSTER_ROOT /node_modules:$NODE_PATH "
19+ RELATIVE_BOOSTER_PATH=$( realpath --relative-to=" $PROJECT_ROOT " " $BOOSTER_ROOT " )
1820fi
1921
2022# Change to project root to ensure context is correct
@@ -63,39 +65,33 @@ run_in_ddev_container() {
6365 if [ -n " $project_name " ]; then
6466 # Use docker exec -t for TTY support and colors
6567 # Forward a conservative whitelist of environment variables from the host
66- # into the container so ZX hooks and wrappers can honour skip flags and
67- # verbosity settings without exposing unrelated host environment values.
68- # Whitelist derived from hook/utility usage and documented in hook comments:
6968 whitelist=(
70- " SKIP_PRECOMMIT"
71- " SKIP_PREPUSH"
72- " SKIP_COMMITMSG"
73- " SKIP_ESLINT"
74- " SKIP_PRETTIER"
75- " SKIP_STYLELINT"
76- " SKIP_RECTOR"
77- " SKIP_ECS"
78- " SKIP_PHPSTAN"
79- " SKIP_PSALM"
80- " SKIP_DEPTRAC"
81- " SKIP_PHPUNIT"
82- " SKIP_API_DOCS"
83- " GIT_HOOKS_VERBOSE"
69+ " SKIP_PRECOMMIT" " SKIP_PREPUSH" " SKIP_COMMITMSG"
70+ " SKIP_ESLINT" " SKIP_PRETTIER" " SKIP_STYLELINT"
71+ " SKIP_RECTOR" " SKIP_ECS" " SKIP_PHPSTAN" " SKIP_PSALM" " SKIP_DEPTRAC"
72+ " SKIP_PHPUNIT" " SKIP_API_DOCS" " GIT_HOOKS_VERBOSE"
8473 )
8574
8675 env_flags=()
8776 for var in " ${whitelist[@]} " ; do
88- # Only forward if variable is set in the host environment
8977 if [ -n " ${! var+x} " ]; then
9078 env_flags+=(" -e" " ${var} =${! var} " )
9179 fi
9280 done
9381
94- if [ ${# env_flags[@]} -gt 0 ]; then
95- exec docker exec -t " ${env_flags[@]} " " $container_name " " $@ "
96- else
97- exec docker exec -t " $container_name " " $@ "
82+ # Construct PATH to include project binaries
83+ # We need both node_modules/.bin (for zx, commitlint) and vendor/bin (for PHP tools)
84+ # These are located at the project root (/var/www/html) in the container
85+ local container_path=" /var/www/html/node_modules/.bin:/var/www/html/vendor/bin"
86+
87+ # If running from a subdirectory (e.g. dev mode), add those paths too
88+ if [ -n " $RELATIVE_BOOSTER_PATH " ]; then
89+ container_path=" /var/www/html/$RELATIVE_BOOSTER_PATH /node_modules/.bin:/var/www/html/$RELATIVE_BOOSTER_PATH /vendor/bin:$container_path "
9890 fi
91+
92+ # Execute command in container with updated PATH
93+ exec docker exec -t " ${env_flags[@]} " " $container_name " \
94+ sh -c " export PATH=$container_path :\$ PATH; exec \"\$ @\" " -- " $@ "
9995 fi
10096}
10197
0 commit comments