Skip to content

Commit

Permalink
fixup: set json config in pkg get explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed May 15, 2024
1 parent 804db2c commit 80e6de4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 2 additions & 0 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ class Npm {

output.flush({
[META]: true,
// json can be set during a command so we send the
// final value of it to the display layer here
json: this.config.get('json'),
jsonError: jsonError(err, this),
})
Expand Down
14 changes: 5 additions & 9 deletions lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ class Display {
#command
#levelIndex
#timing
#jsonConfig
#jsonOutput
#json
#heading
#silent

Expand Down Expand Up @@ -209,11 +208,6 @@ class Display {
}
}

// We are in json mode if set from the config or if jsonOutput is set via a handler
get #json () {
return this.#jsonConfig || this.#jsonOutput
}

async load ({
command,
heading,
Expand Down Expand Up @@ -245,7 +239,7 @@ class Display {
this.#command = command
this.#levelIndex = LEVEL_OPTIONS[loglevel].index
this.#timing = timing
this.#jsonConfig = json
this.#json = json
this.#heading = heading
this.#silent = this.#levelIndex <= 0

Expand Down Expand Up @@ -296,7 +290,9 @@ class Display {
// Arrow function assigned to a private class field so it can be passed
// directly as a listener and still reference "this"
#outputHandler = withMeta((level, meta, ...args) => {
this.#jsonOutput = meta.json
if (typeof meta.json === 'boolean') {
this.#json = meta.json
}
switch (level) {
case output.KEYS.flush: {
this.#outputState.buffering = false
Expand Down

0 comments on commit 80e6de4

Please sign in to comment.