Skip to content

Commit 8d8df0b

Browse files
committed
refactor: update runWithRunner and runVendorBin to return ProcessOutput type
1 parent 36bec71 commit 8d8df0b

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

booster/tools/git-hooks/shared/runner.sh

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22

33
# Generic runner script - handles DDEV container detection and command execution
44

5-
# Force color output to preserve colors through shell layers and WSL
6-
export FORCE_COLOR=1
7-
export CLICOLOR_FORCE=1
8-
export NO_COLOR=
9-
export TERM=${TERM:-xterm-256color}
10-
# Ensure Node.js tools output colors
11-
export NPM_CONFIG_COLOR=always
12-
export PNPM_CONFIG_COLOR=always
13-
145
# Check if we're inside a DDEV container
156
is_inside_container() {
167
[[ -n "$DDEV_HOSTNAME" || -n "$DDEV_PROJECT" || -n "$DDEV_SITENAME" ]]
@@ -30,15 +21,12 @@ elif command -v ddev >/dev/null 2>&1; then
3021
if [ -f ".ddev/config.yaml" ]; then
3122
project_name=$(grep "^name:" .ddev/config.yaml | sed 's/name: *//' | tr -d '"')
3223
container_name="ddev-${project_name}-web"
33-
24+
3425
if [ -n "$project_name" ] && command -v docker >/dev/null 2>&1; then
3526
# Use docker exec -t for TTY support and colors
3627
exec docker exec -t "$container_name" "$@"
3728
fi
3829
fi
39-
40-
# Fallback to ddev exec (no colors but still works)
41-
exec ddev exec "$@"
4230
else
4331
exec "$@"
44-
fi
32+
fi

booster/tools/git-hooks/shared/utils.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Provides consistent logging, file operations, and tool detection
66
*/
77

8-
import { $, chalk, fs, path } from 'zx'
8+
import { $, chalk, fs, path, ProcessOutput } from 'zx'
99

1010
// Configure zx behavior
1111
$.verbose = false
@@ -26,7 +26,10 @@ interface RunOptions {
2626
* @param command Array of command parts
2727
* @param options Execution options
2828
*/
29-
export async function runWithRunner(command: string[], options: RunOptions = {}): Promise<any> {
29+
export async function runWithRunner(
30+
command: string[],
31+
options: RunOptions = {},
32+
): Promise<ProcessOutput> {
3033
const { quiet = false } = options
3134

3235
// Log command execution if not quiet
@@ -73,7 +76,7 @@ export async function getStagedPhpFiles(): Promise<string[]> {
7376
// Filter for PHP files that actually exist
7477
const phpFiles: string[] = []
7578
for (const file of allFiles) {
76-
if (file.endsWith('.php') && !file.includes('/vendor/') && (await fs.pathExists(file))) {
79+
if (file.endsWith('.php') && !file.startsWith('vendor/') && (await fs.pathExists(file))) {
7780
phpFiles.push(file)
7881
}
7982
}
@@ -180,7 +183,7 @@ export async function hasComposerPackage(packageName: string): Promise<boolean>
180183
* @param toolName Name of the tool
181184
* @param args Arguments to pass to the tool
182185
*/
183-
export async function runVendorBin(toolName: string, args: string[] = []): Promise<any> {
186+
export async function runVendorBin(toolName: string, args: string[] = []): Promise<ProcessOutput> {
184187
const command = [`./vendor/bin/${toolName}`, ...args]
185188
return await runWithRunner(command)
186189
}

0 commit comments

Comments
 (0)