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 11a49f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
4 changes: 3 additions & 1 deletion lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ class Npm {

output.flush({
[META]: true,
json: this.config.get('json'),
// json can be set during a command so we send the
// final value of it to the display layer here
json: this.loaded && this.config.get('json'),
jsonError: jsonError(err, this),
})

Expand Down
12 changes: 3 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,7 @@ 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
this.#json = typeof meta.json === 'boolean' ? meta.json : this.#json
switch (level) {
case output.KEYS.flush: {
this.#outputState.buffering = false
Expand Down

0 comments on commit 11a49f9

Please sign in to comment.