/
usr
/
local
/
lib
/
node_modules
/
npm
/
lib
/
utils
/
/usr/local/lib/node_modules/npm/lib/utils
mkdir
upload
Name
Size
Mode
Actions
audit-error.js
1078
0644
edit
dl
rm
auth.js
3288
0644
edit
dl
rm
cmd-list.js
2953
0644
edit
dl
rm
completion.fish
1596
0644
edit
dl
rm
completion.sh
1898
0755
edit
dl
rm
did-you-mean.js
1143
0644
edit
dl
rm
display.js
16760
0644
edit
dl
rm
error-message.js
15775
0644
edit
dl
rm
explain-dep.js
3648
0644
edit
dl
rm
explain-eresolve.js
2582
0644
edit
dl
rm
format-bytes.js
624
0644
edit
dl
rm
format-search-stream.js
4913
0644
edit
dl
rm
format.js
2140
0644
edit
dl
rm
get-identity.js
797
0644
edit
dl
rm
get-workspaces.js
1748
0644
edit
dl
rm
installed-deep.js
1129
0644
edit
dl
rm
installed-shallow.js
583
0644
edit
dl
rm
is-windows.js
177
0644
edit
dl
rm
log-file.js
7860
0644
edit
dl
rm
npm-usage.js
2072
0644
edit
dl
rm
oidc.js
7368
0644
edit
dl
rm
open-url.js
2553
0644
edit
dl
rm
output-error.js
788
0644
edit
dl
rm
ping.js
265
0644
edit
dl
rm
queryable.js
9611
0644
edit
dl
rm
read-user-info.js
2095
0644
edit
dl
rm
reify-finish.js
753
0644
edit
dl
rm
reify-output.js
6475
0644
edit
dl
rm
sbom-cyclonedx.js
5656
0644
edit
dl
rm
sbom-spdx.js
5288
0644
edit
dl
rm
tar.js
3511
0644
edit
dl
rm
timers.js
2120
0644
edit
dl
rm
update-workspaces.js
997
0644
edit
dl
rm
validate-lockfile.js
1023
0644
edit
dl
rm
verify-signatures.js
12499
0644
edit
dl
rm
Edit:
/usr/local/lib/node_modules/npm/lib/utils/format.js
(2140B)
// All logging goes through here, both to console and log files const { formatWithOptions: baseFormatWithOptions } = require('node:util') const { redactLog } = require('@npmcli/redact') // These are most assuredly not a mistake // https://eslint.org/docs/latest/rules/no-control-regex // \x00 through \x1f, \x7f through \x9f, not including \x09 \x0a \x0b \x0d /* eslint-disable-next-line no-control-regex */ const HAS_C01 = /[\x00-\x08\x0c\x0e-\x1f\x7f-\x9f]/ // Allows everything up to '[38;5;255m' in 8 bit notation const ALLOWED_SGR = /^\[[0-9;]{0,8}m/ // '[38;5;255m'.length const SGR_MAX_LEN = 10 // Strips all ANSI C0 and C1 control characters (except for SGR up to 8 bit) function STRIP_C01 (str) { if (!HAS_C01.test(str)) { return str } let result = '' for (let i = 0; i < str.length; i++) { const char = str[i] const code = char.charCodeAt(0) if (!HAS_C01.test(char)) { // Most characters are in this set so continue early if we can result = `${result}${char}` } else if (code === 27 && ALLOWED_SGR.test(str.slice(i + 1, i + SGR_MAX_LEN + 1))) { // \x1b with allowed SGR result = `${result}\x1b` } else if (code <= 31) { // escape all other C0 control characters besides \x7f result = `${result}^${String.fromCharCode(code + 64)}` } else { // hasC01 ensures this is now a C1 control character or \x7f result = `${result}^${String.fromCharCode(code - 64)}` } } return result } const formatWithOptions = ({ prefix: prefixes = [], eol = '\n', redact = true, ...options }, ...args) => { const prefix = prefixes.filter(p => p != null).join(' ') let formatted = STRIP_C01(baseFormatWithOptions(options, ...args)) if (redact) { 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/) return lines.reduce((acc, l) => `${acc}${prefix}${prefix && l ? ' ' : ''}${l}${eol}`, '') } module.exports = { formatWithOptions }
Save
cmd:
run