@@ -18,64 +18,17 @@ interface RunOptions {
1818}
1919
2020/**
21- * Check if we're already inside a DDEV container
22- */
23- async function isInsideDdevContainer ( ) : Promise < boolean > {
24- try {
25- // Check for CI environment first - in CI we should use DDEV commands explicitly
26- if ( process . env . CI === 'true' || process . env . GITHUB_ACTIONS === 'true' ) {
27- return false // In CI, always use ddev exec commands
28- }
29-
30- // Check for DDEV_HOSTNAME environment variable (most reliable)
31- if ( process . env . DDEV_HOSTNAME ) {
32- return true
33- }
34-
35- // Check for specific DDEV environment variables
36- if ( process . env . DDEV_PROJECT || process . env . DDEV_SITENAME ) {
37- return true
38- }
39-
40- // Check if we're inside a container by examining hostname or other indicators
41- const result = await $ `hostname` . quiet ( )
42- const hostname = result . toString ( ) . trim ( )
43-
44- // Check for DDEV container indicators
45- return hostname . includes ( 'ddev' ) || hostname . includes ( 'web' )
46- } catch ( error ) {
47- return false
48- }
49- }
50-
51- /**
52- * Execute command with appropriate runner (DDEV or direct)
21+ * Execute command directly with ZX
5322 * @param command Array of command parts
5423 * @param options Execution options
5524 */
5625export async function runWithRunner ( command : string [ ] , options : RunOptions = { } ) : Promise < any > {
5726 const { quiet = false } = options
5827
59- // Build command array
60- let fullCommand : string [ ]
61- let contextLabel : string
62-
63- const isInsideContainer = await isInsideDdevContainer ( )
64-
65- if ( ! isInsideContainer ) {
66- // We're not inside a container - run via DDEV
67- fullCommand = [ 'ddev' , 'exec' , ...command ]
68- contextLabel = 'via DDEV'
69- } else {
70- // Run directly (already inside container)
71- fullCommand = command
72- contextLabel = isInsideContainer ? 'inside DDEV container' : 'direct'
73- }
74-
7528 // Log command execution if not quiet
7629 if ( ! quiet ) {
7730 const commandStr = command . join ( ' ' )
78- log . info ( `Executing ( ${ contextLabel } ) : ${ commandStr } ` )
31+ log . info ( `Executing: ${ commandStr } ` )
7932 }
8033
8134 // Set clean environment to avoid locale warnings
@@ -87,26 +40,11 @@ export async function runWithRunner(command: string[], options: RunOptions = {})
8740
8841 try {
8942 // Execute with appropriate stdio handling and clean environment
90- return await $ ( { stdio : quiet ? 'pipe' : 'inherit' , env : cleanEnv } ) `${ fullCommand } `
43+ return await $ ( { stdio : quiet ? 'pipe' : 'inherit' , env : cleanEnv } ) `${ command } `
9144 } catch ( error : unknown ) {
92- // Add better error context for debugging CI issues
93- const errorMessage = error instanceof Error ? error . message : String ( error )
94- const commandStr = fullCommand . join ( ' ' )
95- log . error ( `Command failed: ${ commandStr } ` )
96- log . error ( `Error: ${ errorMessage } ` )
97- log . error ( `Context: ${ contextLabel } ` )
98- log . error ( `Working directory: ${ process . cwd ( ) } ` )
99-
100- // In CI environments, also log environment details for debugging
101- if ( process . env . CI === 'true' || process . env . GITHUB_ACTIONS === 'true' ) {
102- log . error ( `CI Environment detected` )
103- log . error ( `Container detection result: inside=${ isInsideContainer } ` )
104- }
105-
10645 throw error
10746 }
10847}
109-
11048/**
11149 * Logging utilities with consistent formatting
11250 */
0 commit comments