22
33const dotenv = require ( 'dotenv' ) ;
44const dotenvExpand = require ( 'dotenv-expand' ) ;
5- const { execSync } = require ( 'child_process' ) ;
5+ const { execSync, spawnSync } = require ( 'child_process' ) ;
66const local_env_utils = require ( './utils' ) ;
77const { constants, copyFile } = require ( 'node:fs' ) ;
88
@@ -34,15 +34,34 @@ const containers = [ 'wordpress-develop', 'cli' ];
3434if ( process . env . LOCAL_PHP_MEMCACHED === 'true' ) {
3535 containers . push ( 'memcached' ) ;
3636}
37- execSync ( `docker compose ${ composeFiles } up --quiet-pull -d ${ containers . join ( ' ' ) } ` , { stdio : 'inherit' } ) ;
37+
38+ spawnSync (
39+ 'docker' ,
40+ [
41+ 'compose' ,
42+ ...composeFiles . map ( ( composeFile ) => [ '-f' , composeFile ] ) . flat ( ) ,
43+ 'up' ,
44+ '--quiet-pull' ,
45+ '-d' ,
46+ ...containers ,
47+ ] ,
48+ { stdio : 'inherit' }
49+ ) ;
3850
3951// If Docker Toolbox is being used, we need to manually forward LOCAL_PORT to the Docker VM.
4052if ( process . env . DOCKER_TOOLBOX_INSTALL_PATH ) {
4153 // VBoxManage is added to the PATH on every platform except Windows.
4254 const vboxmanage = process . env . VBOX_MSI_INSTALL_PATH ? `${ process . env . VBOX_MSI_INSTALL_PATH } /VBoxManage` : 'VBoxManage' ;
4355
4456 // Check if the port forwarding is already configured for this port.
45- const vminfoBuffer = execSync ( `"${ vboxmanage } " showvminfo "${ process . env . DOCKER_MACHINE_NAME } " --machinereadable` ) ;
57+ const vminfoBuffer = spawnSync (
58+ vboxmanage ,
59+ [
60+ 'showvminfo' ,
61+ process . env . DOCKER_MACHINE_NAME ,
62+ '--machinereadable'
63+ ]
64+ ) . stdout ;
4665 const vminfo = vminfoBuffer . toString ( ) . split ( / [ \r \n ] + / ) ;
4766
4867 vminfo . forEach ( ( info ) => {
@@ -56,10 +75,29 @@ if ( process.env.DOCKER_TOOLBOX_INSTALL_PATH ) {
5675
5776 // Delete rules that are using the port we need.
5877 if ( rule [ 3 ] === process . env . LOCAL_PORT || rule [ 5 ] === process . env . LOCAL_PORT ) {
59- execSync ( `"${ vboxmanage } " controlvm "${ process . env . DOCKER_MACHINE_NAME } " natpf1 delete ${ rule [ 0 ] } ` , { stdio : 'inherit' } ) ;
78+ spawnSync (
79+ vboxmanage ,
80+ [
81+ 'controlvm' ,
82+ process . env . DOCKER_MACHINE_NAME ,
83+ 'natpf1' ,
84+ 'delete' ,
85+ rule [ 0 ]
86+ ] ,
87+ { stdio : 'inherit' }
88+ ) ;
6089 }
6190 } ) ;
6291
6392 // Add our port forwarding rule.
64- execSync ( `"${ vboxmanage } " controlvm "${ process . env . DOCKER_MACHINE_NAME } " natpf1 "tcp-port${ process . env . LOCAL_PORT } ,tcp,127.0.0.1,${ process . env . LOCAL_PORT } ,,${ process . env . LOCAL_PORT } "` , { stdio : 'inherit' } ) ;
93+ spawnSync (
94+ vboxmanage ,
95+ [
96+ 'controlvm' ,
97+ process . env . DOCKER_MACHINE_NAME ,
98+ 'natpf1' ,
99+ `tcp-port${ process . env . LOCAL_PORT } ,tcp,127.0.0.1,${ process . env . LOCAL_PORT } ,,${ process . env . LOCAL_PORT } `
100+ ] ,
101+ { stdio : 'inherit' }
102+ ) ;
65103}
0 commit comments