@@ -8,36 +8,31 @@ let executionOptions = {
8
8
} ;
9
9
10
10
function logWithPrefix ( prefix , message ) {
11
- let formattedMessage = message . trim ( ) . split ( '\n' )
12
- . reduce ( ( acc , line ) => `${ acc } ${ acc !== '' ? '\n' : '' } ${ prefix } ${ line } ` , '' ) ;
13
-
14
- console . log ( formattedMessage ) ;
11
+ console . log (
12
+ message . toString ( ) . trim ( )
13
+ . split ( '\n' )
14
+ . map ( ( line ) => `${ prefix . grey } ${ line } ` )
15
+ . join ( '\n' )
16
+ ) ;
15
17
}
16
18
17
19
function execWrapper ( command , options = { } ) {
18
20
let proc = exec ( command , options ) ;
19
- let title = options . title || command ;
20
- let log = message => logWithPrefix ( `[${ title } ]` . grey , message ) ;
21
-
22
- if ( executionOptions . verbose ) {
23
- let output = ( data , type ) => {
24
- logWithPrefix ( `[${ title } ] ${ type } :` . grey , data . toString ( ) ) ;
25
- } ;
26
- proc = proc . progress ( ( { stdout, stderr} ) => {
27
- stdout . on ( 'data' , data => output ( data , 'stdout' ) ) ;
28
- stderr . on ( 'data' , data => output ( data , 'stderr' ) ) ;
29
- } )
30
- . then ( result => {
31
- log ( 'Complete' . cyan ) ;
32
- return result ;
33
- } )
34
- . catch ( err => {
35
- log ( `ERROR: ${ err . toString ( ) } ` . red ) ;
36
- throw err ;
37
- } ) ;
21
+ if ( ! executionOptions . verbose ) {
22
+ return proc ;
38
23
}
39
24
40
- return proc ;
25
+ let title = options . title || command ;
26
+ let output = ( data , type ) => logWithPrefix ( `[${ title } ] ${ type } :` , data ) ;
27
+
28
+ return proc . progress ( ( { stdout, stderr} ) => {
29
+ stdout . on ( 'data' , data => output ( data , 'stdout' ) ) ;
30
+ stderr . on ( 'data' , data => output ( data , 'stderr' ) ) ;
31
+ } )
32
+ . then ( result => {
33
+ logWithPrefix ( `[${ title } ]` , 'Complete' . cyan ) ;
34
+ return result ;
35
+ } ) ;
41
36
}
42
37
43
38
function safeExec ( command , options = { } ) {
0 commit comments