Skip to content

Commit

Permalink
small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
sirenkovladd committed Jan 24, 2024
1 parent ec77e81 commit 6977f89
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/cli-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module.exports = async (process, validateEngines) => {
// set it here so that regardless of what happens later, we don't
// leak any private CLI configs to other programs
process.title = 'npm'

// if npm is called as "npmg" or "npm_g", then run in global mode.
if (process.argv[1][process.argv[1].length - 1] === 'g') {
Expand Down Expand Up @@ -57,7 +56,7 @@ module.exports = async (process, validateEngines) => {
process.exitCode = 1
return exitHandler()
}

setTimeout(() => process.title = npm.title)
await npm.exec(cmd)
return exitHandler()
} catch (err) {
Expand Down
3 changes: 1 addition & 2 deletions lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const LogFile = require('./utils/log-file.js')
const Timers = require('./utils/timers.js')
const Display = require('./utils/display.js')
const log = require('./utils/log-shim')
const replaceInfo = require('./utils/replace-info.js')
const updateNotifier = require('./utils/update-notifier.js')
const pkg = require('../package.json')
const { deref } = require('./utils/cmd-list.js')
Expand Down Expand Up @@ -177,7 +176,6 @@ class Npm {
}

set title (t) {
process.title = t
this.#title = t
}

Expand Down Expand Up @@ -227,6 +225,7 @@ class Npm {
// note: this MUST be shorter than the actual argv length, because it
// uses the same memory, so node will truncate it if it's too long.
this.time('npm:load:setTitle', () => {
const replaceInfo = require('./utils/replace-info.js')
const { parsedArgv: { cooked, remain } } = this.config
this.argv = remain
// Secrets are mostly in configs, so title is set using only the positional args
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/replace-info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { cleanUrl } = require('npm-registry-fetch')
const cleanUrl = require('npm-registry-fetch/lib/clean-url')
const isString = (v) => typeof v === 'string'

// split on \s|= similar to how nopt parses options
Expand Down

0 comments on commit 6977f89

Please sign in to comment.