@@ -267,16 +267,22 @@ class Display {
267
267
if ( this . #outputState. buffering ) {
268
268
this . #outputState. buffer . push ( [ level , meta , ...args ] )
269
269
} else {
270
- // HACK: if it looks like the banner and we are in a state where we hide the
271
- // banner then dont write any output. This hack can be replaced with proc-log.META
272
- const isBanner = args . length === 1 &&
273
- typeof args [ 0 ] === 'string' &&
274
- args [ 0 ] . startsWith ( '\n> ' ) &&
275
- args [ 0 ] . endsWith ( '\n' )
276
- const hideBanner = this . #silent || [ 'exec' , 'explore' ] . includes ( this . #command)
277
- if ( ! ( isBanner && hideBanner ) ) {
278
- this . #writeOutput( level , meta , ...args )
270
+ // HACK: Check if the argument looks like a run-script banner. This can be
271
+ // replaced with proc-log.META in @npmcli/run-script
272
+ if ( typeof args [ 0 ] === 'string' && args [ 0 ] . startsWith ( '\n> ' ) && args [ 0 ] . endsWith ( '\n' ) ) {
273
+ if ( this . #silent || [ 'exec' , 'explore' ] . includes ( this . #command) ) {
274
+ // Silent mode and some specific commands always hide run script banners
275
+ break
276
+ } else if ( this . #json) {
277
+ // In json mode, change output to stderr since we dont want to break json
278
+ // parsing on stdout if the user is piping to jq or something.
279
+ // XXX: in a future (breaking?) change it might make sense for run-script to
280
+ // always output these banners with proc-log.output.error if we think they
281
+ // align closer with "logging" instead of "output"
282
+ level = output . KEYS . error
283
+ }
279
284
}
285
+ this . #writeOutput( level , meta , ...args )
280
286
}
281
287
break
282
288
}
0 commit comments