File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,24 +7,30 @@ import {spawn} from 'node:child_process'
77
88function spawnPromisified ( command , args , { quiet = false , ...options } = { } ) {
99 return new Promise ( ( resolve , reject ) => {
10- const proc = spawn ( command , args , options )
11- proc . stdout . setEncoding ( 'utf8' )
12- proc . stdout . on ( 'data' , data => {
13- if ( ! quiet ) {
14- console . log ( data )
15- }
16- } )
17- proc . stderr . setEncoding ( 'utf8' )
18- proc . stderr . on ( 'data' , data => {
19- console . error ( data )
20- } )
21- proc . on ( 'close' , code => {
22- if ( code !== 0 ) {
23- reject ( code )
24- } else {
25- resolve ( code )
26- }
27- } )
10+ try {
11+ const proc = spawn ( command , args , options )
12+ proc . stdout . setEncoding ( 'utf8' )
13+ proc . stdout . on ( 'data' , data => {
14+ if ( ! quiet ) {
15+ console . log ( data )
16+ }
17+ } )
18+ proc . stderr . setEncoding ( 'utf8' )
19+ proc . stderr . on ( 'data' , data => {
20+ console . log ( 'error on read data' , data )
21+ console . error ( data )
22+ } )
23+ proc . on ( 'close' , code => {
24+ if ( code !== 0 ) {
25+ reject ( code )
26+ } else {
27+ resolve ( code )
28+ }
29+ } )
30+ } catch ( error ) {
31+ console . log ( 'error on catch: ' , error )
32+ reject ( error )
33+ }
2834 } )
2935}
3036
You can’t perform that action at this time.
0 commit comments