@@ -11,7 +11,7 @@ const usage = require('./utils/npm-usage.js')
11
11
const LogFile = require('./utils/log-file.js')
12
12
const Timers = require('./utils/timers.js')
13
13
const Display = require('./utils/display.js')
14
-
const { log } = require('proc-log')
14
+
const { log, time } = require('proc-log')
15
15
const { redactLog: replaceInfo } = require('@npmcli/redact')
16
16
const updateNotifier = require('./utils/update-notifier.js')
17
17
const pkg = require('../package.json')
@@ -110,7 +110,7 @@ class Npm {
110
110
async exec (cmd, args = this.argv) {
111
111
const command = this.setCmd(cmd)
112
112
113
-
const timeEnd = this.time(`command:${cmd}`)
113
+
const timeEnd = time.start(`command:${cmd}`)
114
114
115
115
// this is async but we dont await it, since its ok if it doesnt
116
116
// finish before the command finishes running. it uses command and argv
@@ -137,7 +137,7 @@ class Npm {
137
137
138
138
async load () {
139
139
if (!this.#loadPromise) {
140
-
this.#loadPromise = this.time('npm:load', () => this.#load().catch((er) => {
140
+
this.#loadPromise = time.start('npm:load', () => this.#load().catch((er) => {
141
141
this.loadErr = er
142
142
throw er
143
143
}))
@@ -158,10 +158,6 @@ class Npm {
158
158
this.#logFile.off()
159
159
}
160
160
161
-
time (name, fn) {
162
-
return this.#timers.time(name, fn)
163
-
}
164
-
165
161
writeTimingFile () {
166
162
this.#timers.writeFile({
167
163
id: this.#runId,
@@ -181,7 +177,7 @@ class Npm {
181
177
}
182
178
183
179
async #load () {
184
-
await this.time('npm:load:whichnode', async () => {
180
+
await time.start('npm:load:whichnode', async () => {
185
181
// TODO should we throw here?
186
182
const node = await which(process.argv[0]).catch(() => {})
187
183
if (node && node.toUpperCase() !== process.execPath.toUpperCase()) {
@@ -191,7 +187,7 @@ class Npm {
191
187
}
192
188
})
193
189
194
-
await this.time('npm:load:configload', () => this.config.load())
190
+
await time.start('npm:load:configload', () => this.config.load())
195
191
196
192
// get createSupportsColor from chalk directly if this lands
197
193
// https://github.com/chalk/chalk/pull/600
@@ -211,21 +207,21 @@ class Npm {
211
207
// a different location. if this fails, then we don't have
212
208
// a cache dir, but we don't want to fail immediately since
213
209
// the command might not need a cache dir (like `npm --version`)
214
-
await this.time('npm:load:mkdirpcache', () =>
210
+
await time.start('npm:load:mkdirpcache', () =>
215
211
fs.mkdir(this.cache, { recursive: true })
216
212
.catch((e) => log.verbose('cache', `could not create cache: ${e}`)))
217
213
218
214
// it's ok if this fails. user might have specified an invalid dir
219
215
// which we will tell them about at the end
220
216
if (this.config.get('logs-max') > 0) {
221
-
await this.time('npm:load:mkdirplogs', () =>
217
+
await time.start('npm:load:mkdirplogs', () =>
222
218
fs.mkdir(this.logsDir, { recursive: true })
223
219
.catch((e) => log.verbose('logfile', `could not create logs-dir: ${e}`)))
224
220
}
225
221
226
222
// note: this MUST be shorter than the actual argv length, because it
227
223
// uses the same memory, so node will truncate it if it's too long.
228
-
this.time('npm:load:setTitle', () => {
224
+
time.start('npm:load:setTitle', () => {
229
225
const { parsedArgv: { cooked, remain } } = this.config
230
226
this.argv = remain
231
227
// Secrets are mostly in configs, so title is set using only the positional args
@@ -241,7 +237,7 @@ class Npm {
241
237
log.verbose('argv', this.#argvClean.map(JSON.stringify).join(' '))
242
238
})
243
239
244
-
this.time('npm:load:display', () => {
240
+
time.start('npm:load:display', () => {
245
241
this.#display.load({
246
242
loglevel: this.config.get('loglevel'),
247
243
// TODO: only pass in logColor and color and create chalk instances
@@ -260,21 +256,21 @@ class Npm {
260
256
process.env.COLOR = this.color ? '1' : '0'
261
257
})
262
258
263
-
this.time('npm:load:logFile', () => {
259
+
time.start('npm:load:logFile', () => {
264
260
this.#logFile.load({
265
261
path: this.logPath,
266
262
logsMax: this.config.get('logs-max'),
267
263
})
268
264
log.verbose('logfile', this.#logFile.files[0] || 'no logfile created')
269
265
})
270
266
271
-
this.time('npm:load:timers', () =>
267
+
time.start('npm:load:timers', () =>
272
268
this.#timers.load({
273
269
path: this.config.get('timing') ? this.logPath : null,
274
270
})
275
271
)
276
272
277
-
this.time('npm:load:configScope', () => {
273
+
time.start('npm:load:configScope', () => {
278
274
const configScope = this.config.get('scope')
279
275
if (configScope && !/^@/.test(configScope)) {
280
276
this.config.set('scope', `@${configScope}`, this.config.find('scope'))
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4