Skip to content

Commit 18bfc47

Browse files
committed
fix: hide banner for exec and explore
1 parent 9fea383 commit 18bfc47

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/npm.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ class Npm {
174174
progress: this.flatOptions.progress,
175175
json: this.config.get('json'),
176176
heading: this.config.get('heading'),
177+
// TODO: avoid passing all of npm in. this is a quick
178+
// fix to allow display to know the currently running command
179+
npm: this,
177180
})
178181
process.env.COLOR = this.color ? '1' : '0'
179182

lib/utils/display.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class Display {
124124
#json
125125
#heading
126126
#silent
127+
#npm
127128

128129
// display streams
129130
#stdout
@@ -167,7 +168,9 @@ class Display {
167168
stdoutColor,
168169
timing,
169170
unicode,
171+
npm,
170172
}) {
173+
this.#npm = npm
171174
// get createSupportsColor from chalk directly if this lands
172175
// https://github.com/chalk/chalk/pull/600
173176
const [{ Chalk }, { createSupportsColor }] = await Promise.all([
@@ -273,9 +276,10 @@ class Display {
273276
}
274277

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

0 commit comments

Comments
 (0)