diff --git a/lib/npm.js b/lib/npm.js index 5c42dbe57f183..461a10bc7e8d2 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -100,6 +100,7 @@ class Npm { const command = deref(commandArg) await this.#display.load({ + command, loglevel: this.config.get('loglevel'), stdoutColor: this.color, stderrColor: this.logColor, diff --git a/lib/utils/display.js b/lib/utils/display.js index 4030c8e32b931..0ee41ead31ad5 100644 --- a/lib/utils/display.js +++ b/lib/utils/display.js @@ -171,6 +171,7 @@ class Display { #progress // options + #command #levelIndex #timing #json @@ -213,6 +214,7 @@ class Display { } async load ({ + command, heading, json, loglevel, @@ -235,6 +237,7 @@ class Display { this.#stderrChalk = stderrColor ? new Chalk({ level }) : this.#noColorChalk this.#logColors = COLOR_PALETTE({ chalk: this.#stderrChalk }) + this.#command = command this.#levelIndex = LEVEL_OPTIONS[loglevel].index this.#timing = timing this.#json = json @@ -382,6 +385,16 @@ class Display { // Also (and this is a really inexcusable kludge), we patch the log.warn() method so that when we see a peerDep override explanation from Arborist, we can replace the object with a highly abbreviated explanation of what's being overridden. // TODO: this could probably be moved to arborist now that display is refactored const [heading, message, expl] = args + // exec has always suppressed the run-script banner, since the command + // being executed owns the terminal output. run-script@11 logs those + // banners as `notice run` messages instead of standard output. + if ( + level === log.KEYS.notice && + heading === 'run' && + ['exec', 'explore'].includes(this.#command) + ) { + return + } if (level === log.KEYS.warn && heading === 'ERESOLVE' && expl && typeof expl === 'object') { this.#writeLog(level, meta, heading, message) this.#writeLog(level, meta, '', explain(expl, this.#stderrChalk, 2)) diff --git a/test/lib/utils/display.js b/test/lib/utils/display.js index b33ab69a36594..b5d331dd27d90 100644 --- a/test/lib/utils/display.js +++ b/test/lib/utils/display.js @@ -203,6 +203,18 @@ t.test('notice deduplication does not apply in verbose mode', async t => { ]) }) +t.test('exec suppresses run-script notices', async t => { + const { log, logs } = await mockDisplay(t, { + load: { command: 'exec' }, + }) + + log.notice('run', 'cypress@1.0.0 npx') + log.notice('run', 'cypress --version') + log.notice('', 'a regular notice') + + t.strictSame(logs.notice, ['a regular notice']) +}) + t.test('Display.clean', async (t) => { const { output, outputs, clearOutput } = await mockDisplay(t)