You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This skips any error checking since we can only set an error property
124
-
// on an object that can be stringified
121
+
// This skips any error checking since we can only set an error property on an object that can be stringified
125
122
// XXX(BREAKING_CHANGE): remove this in favor of always returning an object with result and error keys
126
123
if(isPlainObject(res)&&errors.length){
127
-
// This is not ideal. JSON output has always been keyed at the root with an `error`
128
-
// key, so we cant change that without it being a breaking change. At the same time
129
-
// some commands output arbitrary keys at the top level of the output, such as package
130
-
// names. So the output could already have the same key. The choice here is to overwrite
131
-
// it with our error since that is (probably?) more important.
124
+
// This is not ideal.
125
+
// JSON output has always been keyed at the root with an `error` key, so we cant change that without it being a breaking change. At the same time some commands output arbitrary keys at the top level of the output, such as package names.
126
+
// So the output could already have the same key. The choice here is to overwrite it with our error since that is (probably?) more important.
132
127
// XXX(BREAKING_CHANGE): all json output should be keyed under well known keys, eg `result` and `error`
133
128
if(res[ERROR_KEY]){
134
129
log.warn('',`overwriting existing ${ERROR_KEY} on json output`)
@@ -227,9 +222,7 @@ class Display {
227
222
import('chalk'),
228
223
import('supports-color'),
229
224
])
230
-
// we get the chalk level based on a null stream meaning chalk will only use
231
-
// what it knows about the environment to get color support since we already
232
-
// determined in our definitions that we want to show colors.
225
+
// we get the chalk level based on a null stream meaning chalk will only use what it knows about the environment to get color support since we already determined in our definitions that we want to show colors.
// Silent mode and some specific commands always hide run script banners
324
314
break
325
315
}elseif(this.#json){
326
-
// In json mode, change output to stderr since we don't want to break json
327
-
// parsing on stdout if the user is piping to jq or something.
328
-
// XXX: in a future (breaking?) change it might make sense for run-script to
329
-
// always output these banners with proc-log.output.error if we think they
330
-
// align closer with "logging" instead of "output"
316
+
// In json mode, change output to stderr since we don't want to break json parsing on stdout if the user is piping to jq or something.
317
+
// XXX: in a future (breaking?) change it might make sense for run-script to always output these banners with proc-log.output.error if we think they align closer with "logging" instead of "output"
331
318
level=output.KEYS.error
332
319
}
333
320
}
@@ -352,14 +339,12 @@ class Display {
352
339
break
353
340
354
341
caseinput.KEYS.read: {
355
-
// The convention when calling input.read is to pass in a single fn that returns
356
-
// the promise to await. resolve and reject are provided by proc-log
342
+
// The convention when calling input.read is to pass in a single fn that returns the promise to await. resolve and reject are provided by proc-log
357
343
const[res,rej,p]=args
358
344
returninput.start(()=>p()
359
345
.then(res)
360
346
.catch(rej)
361
-
// Any call to procLog.input.read will render a prompt to the user, so we always
362
-
// add a single newline of output to stdout to move the cursor to the next line
347
+
// Any call to procLog.input.read will render a prompt to the user, so we always add a single newline of output to stdout to move the cursor to the next line
363
348
.finally(()=>output.standard('')))
364
349
}
365
350
}
@@ -383,10 +368,7 @@ class Display {
383
368
384
369
#tryWriteLog (level,meta, ...args){
385
370
try{
386
-
// Also (and this is a really inexcusable kludge), we patch the
387
-
// log.warn() method so that when we see a peerDep override
388
-
// explanation from Arborist, we can replace the object with a
389
-
// highly abbreviated explanation of what's being overridden.
371
+
// Also (and this is a really inexcusable kludge), we patch the log.warn() method so that when we see a peerDep override explanation from Arborist, we can replace the object with a highly abbreviated explanation of what's being overridden.
390
372
// TODO: this could probably be moved to arborist now that display is refactored
this.#writeLog(log.KEYS.verbose,meta,'',`attempt to log crashed`, ...args,ex)
402
384
}catch(ex2){
403
-
// This happens if the object has an inspect method that crashes so just console.error
404
-
// with the errors but don't do anything else that might error again.
385
+
// This happens if the object has an inspect method that crashes so just console.error with the errors but don't do anything else that might error again.
405
386
// eslint-disable-next-line no-console
406
387
console.error(`attempt to log crashed`,ex,ex2)
407
388
}
@@ -421,7 +402,12 @@ class Display {
421
402
this.#logColors[level](level),
422
403
title ? this.#logColors.title(title) : null,
423
404
]
424
-
this.#write(this.#stderr,{ prefix }, ...args)
405
+
constwriteOpts={ prefix }
406
+
// notice logs typically come from `npm-notice` headers in responses. Some of them have 2fa login links so we skip redaction.
407
+
if(level==='notice'){
408
+
writeOpts.redact=false
409
+
}
410
+
this.#write(this.#stderr,writeOpts, ...args)
425
411
}
426
412
}
427
413
}
@@ -480,9 +466,8 @@ class Progress {
480
466
this.#render()
481
467
}
482
468
483
-
// If we are currently rendering the spinner we clear it
484
-
// before writing our line and then re-render the spinner after.
485
-
// If not then all we need to do is write the line
469
+
// If we are currently rendering the spinner we clear it before writing our line and then re-render the spinner after.
470
+
// If not then all we need to do is write the line.
486
471
write(write){
487
472
if(this.#spinning){
488
473
this.#clearSpinner()
@@ -510,8 +495,7 @@ class Progress {
510
495
if(!this.#rendering){
511
496
return
512
497
}
513
-
// We always attempt to render immediately but we only request to move to the next
514
-
// frame if it has been longer than our spinner frame duration since our last update
498
+
// We always attempt to render immediately but we only request to move to the next frame if it has been longer than our spinner frame duration since our last update
0 commit comments