Skip to content

Commit

Permalink
fixup! 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 58fd1cb commit b284b23
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Npm {
updateNotification = null
argv = []

#commandName = null
#command = null
#runId = new Date().toISOString().replace(/[.:]/g, '_')
#title = 'npm'
Expand Down Expand Up @@ -94,14 +93,7 @@ class Npm {
}

async load () {
return time.start('npm:load', async () => {
const { exec, command, args } = await this.#load()
return {
exec,
command,
args,
}
})
return time.start('npm:load', () => this.#load())
}

get loaded () {
Expand Down Expand Up @@ -225,21 +217,21 @@ class Npm {
// We time this because setting process.title is slow sometimes but we
// have to do it for security reasons. But still helpful to know how slow it is.
time.start('npm:load:setTitle', () => {
const { parsedArgv: { cooked, remain } } = this.config
// Secrets are mostly in configs, so title is set using only the positional args
// to keep those from being leaked. We still do a best effort replaceInfo.
this.#title = ['npm'].concat(replaceInfo(this.config.parsedArgv.remain)).join(' ').trim()
this.#title = ['npm'].concat(replaceInfo(remain)).join(' ').trim()
process.title = this.#title
// The cooked argv is also logged separately for debugging purposes. It is
// cleaned as a best effort by replacing known secrets like basic auth
// password and strings that look like npm tokens. XXX: for this to be
// safer the config should create a sanitized version of the argv as it
// has the full context of what each option contains.
this.#argvClean = replaceInfo(cooked)
log.verbose('title', this.title)
log.verbose('argv', this.#argvClean.map(JSON.stringify).join(' '))
})

// The cooked argv is also logged separately for debugging purposes. It is
// cleaned as a best effort by replacing known secrets like basic auth
// password and strings that look like npm tokens. XXX: for this to be
// safer the config should create a sanitized version of the argv as it
// has the full context of what each option contains.
this.#argvClean = replaceInfo(this.config.parsedArgv.cooked)
log.verbose('title', this.title)
log.verbose('argv', this.#argvClean.map(JSON.stringify).join(' '))

// logFile.load returns a promise that resolves when old logs are done being cleaned.
// We save this promise to an array so that we can await it in tests to ensure more
// deterministic logging behavior. The process will also hang open if this were to
Expand Down

0 comments on commit b284b23

Please sign in to comment.