1- import { spawn } from 'child_process'
1+ import { spawn , SpawnOptions } from 'child_process'
22import { createWriteStream } from 'fs'
33import process from 'node:process'
44import { webpack as webpackAsync } from 'webpack'
@@ -25,12 +25,12 @@ const BUNDLE_FILES = [
2525 'CHANGELOG.md'
2626]
2727
28- const execute = ( command : string , ... args : readonly string [ ] ) : Promise < number | null > =>
28+ const execute = ( command : string , args : readonly string [ ] , options : SpawnOptions ) : Promise < number | null > =>
2929 new Promise ( resolve => {
30- const child = spawn ( command , args )
30+ const child = spawn ( command , args , { ... options } )
3131
32- child . stdout . on ( 'data' , ( data : string ) => process . stdout . write ( data ) )
33- child . stderr . on ( 'data' , ( data : string ) => process . stderr . write ( data ) )
32+ child . stdout ? .on ( 'data' , ( data : string ) => process . stdout . write ( data ) )
33+ child . stderr ? .on ( 'data' , ( data : string ) => process . stderr . write ( data ) )
3434 child . on ( 'close' , code => resolve ( code ) )
3535 } )
3636
@@ -57,15 +57,15 @@ const bundle = async () => {
5757
5858 await Promise . all ( [
5959 cleanup ( `${ plugin . name } .*.zip` ) ,
60- execute ( 'composer' , 'install' , '--no-dev' ) ,
60+ execute ( 'composer' , [ 'install' , '--no-dev' ] , { cwd : 'src' } ) ,
6161 webpack ( { mode : 'production' } )
6262 ] )
6363
6464 await copy ( BUNDLE_FILES , DEST_DIR , filename =>
6565 filename . replace ( / ^ s r c \/ / , '' ) )
6666
6767 await createArchive ( )
68- await execute ( 'composer' , 'install' )
68+ await execute ( 'composer' , [ 'install' ] , { cwd : 'src' } )
6969}
7070
7171void bundle ( ) . then ( )
0 commit comments