@@ -11,7 +11,7 @@ const usage = require('./utils/npm-usage.js')
1111const LogFile = require ( './utils/log-file.js' )
1212const Timers = require ( './utils/timers.js' )
1313const Display = require ( './utils/display.js' )
14- const { log } = require ( 'proc-log' )
14+ const { log, time } = require ( 'proc-log' )
1515const { redactLog : replaceInfo } = require ( '@npmcli/redact' )
1616const updateNotifier = require ( './utils/update-notifier.js' )
1717const pkg = require ( '../package.json' )
@@ -110,7 +110,7 @@ class Npm {
110110 async exec ( cmd , args = this . argv ) {
111111 const command = this . setCmd ( cmd )
112112
113- const timeEnd = this . time ( `command:${ cmd } ` )
113+ const timeEnd = time . start ( `command:${ cmd } ` )
114114
115115 // this is async but we dont await it, since its ok if it doesnt
116116 // finish before the command finishes running. it uses command and argv
@@ -137,7 +137,7 @@ class Npm {
137137
138138 async load ( ) {
139139 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 ) => {
141141 this . loadErr = er
142142 throw er
143143 } ) )
@@ -158,10 +158,6 @@ class Npm {
158158 this . #logFile. off ( )
159159 }
160160
161- time ( name , fn ) {
162- return this . #timers. time ( name , fn )
163- }
164-
165161 writeTimingFile ( ) {
166162 this . #timers. writeFile ( {
167163 id : this . #runId,
@@ -181,7 +177,7 @@ class Npm {
181177 }
182178
183179 async #load ( ) {
184- await this . time ( 'npm:load:whichnode' , async ( ) => {
180+ await time . start ( 'npm:load:whichnode' , async ( ) => {
185181 // TODO should we throw here?
186182 const node = await which ( process . argv [ 0 ] ) . catch ( ( ) => { } )
187183 if ( node && node . toUpperCase ( ) !== process . execPath . toUpperCase ( ) ) {
@@ -191,7 +187,7 @@ class Npm {
191187 }
192188 } )
193189
194- await this . time ( 'npm:load:configload' , ( ) => this . config . load ( ) )
190+ await time . start ( 'npm:load:configload' , ( ) => this . config . load ( ) )
195191
196192 // get createSupportsColor from chalk directly if this lands
197193 // https://github.com/chalk/chalk/pull/600
@@ -211,21 +207,21 @@ class Npm {
211207 // a different location. if this fails, then we don't have
212208 // a cache dir, but we don't want to fail immediately since
213209 // 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' , ( ) =>
215211 fs . mkdir ( this . cache , { recursive : true } )
216212 . catch ( ( e ) => log . verbose ( 'cache' , `could not create cache: ${ e } ` ) ) )
217213
218214 // it's ok if this fails. user might have specified an invalid dir
219215 // which we will tell them about at the end
220216 if ( this . config . get ( 'logs-max' ) > 0 ) {
221- await this . time ( 'npm:load:mkdirplogs' , ( ) =>
217+ await time . start ( 'npm:load:mkdirplogs' , ( ) =>
222218 fs . mkdir ( this . logsDir , { recursive : true } )
223219 . catch ( ( e ) => log . verbose ( 'logfile' , `could not create logs-dir: ${ e } ` ) ) )
224220 }
225221
226222 // note: this MUST be shorter than the actual argv length, because it
227223 // 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' , ( ) => {
229225 const { parsedArgv : { cooked, remain } } = this . config
230226 this . argv = remain
231227 // Secrets are mostly in configs, so title is set using only the positional args
@@ -241,7 +237,7 @@ class Npm {
241237 log . verbose ( 'argv' , this . #argvClean. map ( JSON . stringify ) . join ( ' ' ) )
242238 } )
243239
244- this . time ( 'npm:load:display' , ( ) => {
240+ time . start ( 'npm:load:display' , ( ) => {
245241 this . #display. load ( {
246242 loglevel : this . config . get ( 'loglevel' ) ,
247243 // TODO: only pass in logColor and color and create chalk instances
@@ -260,21 +256,21 @@ class Npm {
260256 process . env . COLOR = this . color ? '1' : '0'
261257 } )
262258
263- this . time ( 'npm:load:logFile' , ( ) => {
259+ time . start ( 'npm:load:logFile' , ( ) => {
264260 this . #logFile. load ( {
265261 path : this . logPath ,
266262 logsMax : this . config . get ( 'logs-max' ) ,
267263 } )
268264 log . verbose ( 'logfile' , this . #logFile. files [ 0 ] || 'no logfile created' )
269265 } )
270266
271- this . time ( 'npm:load:timers' , ( ) =>
267+ time . start ( 'npm:load:timers' , ( ) =>
272268 this . #timers. load ( {
273269 path : this . config . get ( 'timing' ) ? this . logPath : null ,
274270 } )
275271 )
276272
277- this . time ( 'npm:load:configScope' , ( ) => {
273+ time . start ( 'npm:load:configScope' , ( ) => {
278274 const configScope = this . config . get ( 'scope' )
279275 if ( configScope && ! / ^ @ / . test ( configScope ) ) {
280276 this . config . set ( 'scope' , `@${ configScope } ` , this . config . find ( 'scope' ) )
0 commit comments