Skip to content

Commit

Permalink
fix: hide banner for exec and explore
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 25, 2024
1 parent 9fea383 commit cd1378c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bin/npx-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,6 @@ if (sawRemovedFlags) {
console.error('See `npm help exec` for more information')
}

console.log(process.argv)

Check failure on line 130 in bin/npx-cli.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement

cli(process)
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')

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

args[0].startsWith is not a function

Check failure on line 280 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

args[0].startsWith is not a function
const hideBanner = this.#silent || ['exec', 'explore'].includes(this.#npm.command)

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.x

Cannot read properties of undefined (reading 'command')

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.x

Cannot read properties of undefined (reading 'command')

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 20.5.0

Cannot read properties of undefined (reading 'command')

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - macOS - 18.17.0

Cannot read properties of undefined (reading 'command')

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.x

Cannot read properties of undefined (reading 'command')

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.x

Cannot read properties of undefined (reading 'command')

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 18.17.0

Cannot read properties of undefined (reading 'command')

Check failure on line 281 in lib/utils/display.js

View workflow job for this annotation

GitHub Actions / Test - Linux - 20.5.0

Cannot read properties of undefined (reading 'command')
if (isBanner && hideBanner) {
return
}

Expand Down

0 comments on commit cd1378c

Please sign in to comment.