Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ class Npm {
progress: this.flatOptions.progress,
json: this.config.get('json'),
heading: this.config.get('heading'),
// TODO: avoid passing all of npm in. this is a quick
// fix to allow display to know the currently running command
npm: this,
})
process.env.COLOR = this.color ? '1' : '0'

Expand Down
10 changes: 7 additions & 3 deletions lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class Display {
#json
#heading
#silent
#npm

// display streams
#stdout
Expand Down Expand Up @@ -167,7 +168,9 @@ class Display {
stdoutColor,
timing,
unicode,
npm,
}) {
this.#npm = npm
// get createSupportsColor from chalk directly if this lands
// https://github.com/chalk/chalk/pull/600
const [{ Chalk }, { createSupportsColor }] = await Promise.all([
Expand Down Expand Up @@ -273,9 +276,10 @@ class Display {
}

// HACK: if it looks like the banner and we are silent do not print it.
// There's no other way to do this right now :(
// eslint-disable-next-line max-len
if (this.#silent && args.length === 1 && args[0].startsWith('\n> ') && args[0].endsWith('\n')) {
// There's no other way to do this right now :(\
const isBanner = args.length === 1 && args[0].startsWith('\n> ') && args[0].endsWith('\n')
const hideBanner = this.#silent || ['exec', 'explore'].includes(this.#npm.command)
if (isBanner && hideBanner) {
return
}

Expand Down