Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class Display {
#progress

// options
#command
#levelIndex
#timing
#json
Expand Down Expand Up @@ -213,6 +214,7 @@ class Display {
}

async load ({
command,
heading,
json,
loglevel,
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand Down
12 changes: 12 additions & 0 deletions test/lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down