diff --git a/lib/npm.js b/lib/npm.js index d7561e0cd03ac..df2297b215da7 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -32,7 +32,6 @@ class Npm { updateNotification = null argv = [] - #commandName = null #command = null #runId = new Date().toISOString().replace(/[.:]/g, '_') #title = 'npm' @@ -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 () { @@ -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