@@ -188,13 +188,14 @@ export async function main(argv: string[]): Promise<any> {
188
188
189
189
const processCallbacks : ( ( child : ChildProcess ) => Promise < void > ) [ ] = [ ] ;
190
190
191
- const verbose = args . verbose ;
192
- if ( verbose ) {
191
+ if ( args . verbose ) {
193
192
env [ 'ELECTRON_ENABLE_LOGGING' ] = '1' ;
193
+ }
194
194
195
+ if ( args . verbose || args . status ) {
195
196
processCallbacks . push ( async child => {
196
197
child . stdout ! . on ( 'data' , ( data : Buffer ) => console . log ( data . toString ( 'utf8' ) . trim ( ) ) ) ;
197
- child . stderr ! . on ( 'data' , ( data : Buffer ) => console . log ( data . toString ( 'utf8' ) . trim ( ) ) ) ;
198
+ child . stderr ? .on ( 'data' , ( data : Buffer ) => console . log ( data . toString ( 'utf8' ) . trim ( ) ) ) ;
198
199
199
200
await Event . toPromise ( Event . fromNodeEventEmitter ( child , 'exit' ) ) ;
200
201
} ) ;
@@ -219,7 +220,7 @@ export async function main(argv: string[]): Promise<any> {
219
220
220
221
// returns a file path where stdin input is written into (write in progress).
221
222
try {
222
- await readFromStdin ( stdinFilePath , ! ! verbose ) ; // throws error if file can not be written
223
+ await readFromStdin ( stdinFilePath , ! ! args . verbose ) ; // throws error if file can not be written
223
224
224
225
// Make sure to open tmp file
225
226
addArg ( argv , stdinFilePath ) ;
@@ -258,7 +259,7 @@ export async function main(argv: string[]): Promise<any> {
258
259
// is closed and then exit the waiting process.
259
260
let waitMarkerFilePath : string | undefined ;
260
261
if ( args . wait ) {
261
- waitMarkerFilePath = createWaitMarkerFileSync ( verbose ) ;
262
+ waitMarkerFilePath = createWaitMarkerFileSync ( args . verbose ) ;
262
263
if ( waitMarkerFilePath ) {
263
264
addArg ( argv , '--waitMarkerFilePath' , waitMarkerFilePath ) ;
264
265
}
@@ -407,13 +408,13 @@ export async function main(argv: string[]): Promise<any> {
407
408
env
408
409
} ;
409
410
410
- if ( ! verbose ) {
411
+ if ( ! args . verbose ) {
411
412
options [ 'stdio' ] = 'ignore' ;
412
413
}
413
414
414
415
let child : ChildProcess ;
415
416
if ( ! isMacOSBigSurOrNewer ) {
416
- if ( ! verbose && args . status ) {
417
+ if ( ! args . verbose && args . status ) {
417
418
options [ 'stdio' ] = [ 'ignore' , 'pipe' , 'ignore' ] ; // restore ability to see output when --status is used
418
419
}
419
420
@@ -435,13 +436,13 @@ export async function main(argv: string[]): Promise<any> {
435
436
// -a opens the given application.
436
437
spawnArgs . push ( '-a' , process . execPath ) ; // -a: opens a specific application
437
438
438
- if ( verbose || args . status ) {
439
+ if ( args . verbose || args . status ) {
439
440
spawnArgs . push ( '--wait-apps' ) ; // `open --wait-apps`: blocks until the launched app is closed (even if they were already running)
440
441
441
442
// The open command only allows for redirecting stderr and stdout to files,
442
443
// so we make it redirect those to temp files, and then use a logger to
443
444
// redirect the file output to the console
444
- for ( const outputType of verbose ? [ 'stdout' , 'stderr' ] : [ 'stdout' ] ) {
445
+ for ( const outputType of args . verbose ? [ 'stdout' , 'stderr' ] : [ 'stdout' ] ) {
445
446
446
447
// Tmp file to target output to
447
448
const tmpName = randomPath ( tmpdir ( ) , `code-${ outputType } ` ) ;
0 commit comments