File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,8 @@ class Npm {
301301
302302 output . flush ( {
303303 [ META ] : true ,
304+ // json can be set during a command so we send the
305+ // final value of it to the display layer here
304306 json : this . config . get ( 'json' ) ,
305307 jsonError : jsonError ( err , this ) ,
306308 } )
Original file line number Diff line number Diff line change @@ -172,8 +172,7 @@ class Display {
172172 #command
173173 #levelIndex
174174 #timing
175- #jsonConfig
176- #jsonOutput
175+ #json
177176 #heading
178177 #silent
179178
@@ -209,11 +208,6 @@ class Display {
209208 }
210209 }
211210
212- // We are in json mode if set from the config or if jsonOutput is set via a handler
213- get #json ( ) {
214- return this . #jsonConfig || this . #jsonOutput
215- }
216-
217211 async load ( {
218212 command,
219213 heading,
@@ -245,7 +239,7 @@ class Display {
245239 this . #command = command
246240 this . #levelIndex = LEVEL_OPTIONS [ loglevel ] . index
247241 this . #timing = timing
248- this . #jsonConfig = json
242+ this . #json = json
249243 this . #heading = heading
250244 this . #silent = this . #levelIndex <= 0
251245
@@ -296,7 +290,9 @@ class Display {
296290 // Arrow function assigned to a private class field so it can be passed
297291 // directly as a listener and still reference "this"
298292 #outputHandler = withMeta ( ( level , meta , ...args ) => {
299- this . #jsonOutput = meta . json
293+ if ( typeof meta . json === 'boolean' ) {
294+ this . #json = meta . json
295+ }
300296 switch ( level ) {
301297 case output . KEYS . flush : {
302298 this . #outputState. buffering = false
You can’t perform that action at this time.
0 commit comments