Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/utils/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ class Display {
// Write formatted and (non-)colorized output to streams
#write (stream, options, ...args) {
const colors = stream === this.#stdout ? this.#stdoutColor : this.#stderrColor
const value = formatWithOptions({ colors, ...options }, ...args)
const skipRedact = args.length > 0 ? args[args.length - 1]?.skipRedact : false
if (skipRedact) {
args = args.slice(0, args.length - 1)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jolyndenning this feels fragile to me. I think we should be able to use the established META pattern - see withMeta. We should be able to avoid this argument parsing

const value = formatWithOptions({ colors, ...options, skipRedact }, ...args)
this.#progress.write(() => stream.write(value))
}

Expand Down
7 changes: 5 additions & 2 deletions lib/utils/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ function STRIP_C01 (str) {
return result
}

const formatWithOptions = ({ prefix: prefixes = [], eol = '\n', ...options }, ...args) => {
const formatWithOptions = ({ prefix: prefixes = [], eol = '\n', skipRedact = false, ...options }, ...args) => {
const prefix = prefixes.filter(p => p != null).join(' ')
const formatted = redactLog(STRIP_C01(baseFormatWithOptions(options, ...args)))
let formatted = STRIP_C01(baseFormatWithOptions(options, ...args))
if (!skipRedact) {
formatted = redactLog(formatted)
}
// Splitting could be changed to only `\n` once we are sure we only emit unix newlines.
// The eol param to this function will put the correct newlines in place for the returned string.
const lines = formatted.split(/\r?\n/)
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/open-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const assertValidUrl = (url) => {

const outputMsg = (json, title, url) => {
if (json) {
output.buffer({ title, url })
output.buffer({ title, url }, { skipRedact: true })
} else {
output.standard(`${title}:\n${url}`)
output.standard(`${title}:\n${url}`, { skipRedact: true })
}
}

Expand Down
Loading