Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logs): clean args for failed commands #3761

Merged
merged 1 commit into from Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/error-message.js
Expand Up @@ -367,7 +367,7 @@ module.exports = (er, npm) => {
detail.push(['signal', er.signal])

if (er.cmd && Array.isArray(er.args))
detail.push(['command', ...[er.cmd, ...er.args]])
detail.push(['command', ...[er.cmd, ...er.args.map(replaceInfo)]])

if (er.stdout)
detail.push(['', er.stdout.trim()])
Expand Down
34 changes: 34 additions & 0 deletions tap-snapshots/test/lib/utils/error-message.js.test.cjs
Expand Up @@ -180,6 +180,40 @@ Object {
}
`

exports[`test/lib/utils/error-message.js TAP args are cleaned > must match snapshot 1`] = `
Object {
"detail": Array [
Array [
"signal",
"SIGYOLO",
],
Array [
"command",
"some command",
"a",
"r",
"g",
"s",
"https://evil:***@npmjs.org",
],
Array [
"",
"stdout",
],
Array [
"",
"stderr",
],
],
"summary": Array [
Array [
"",
"cmd err",
],
],
}
`

exports[`test/lib/utils/error-message.js TAP bad engine with config loaded > must match snapshot 1`] = `
Object {
"detail": Array [
Expand Down
11 changes: 11 additions & 0 deletions test/lib/utils/error-message.js
Expand Up @@ -201,6 +201,17 @@ t.test('default message', t => {
t.end()
})

t.test('args are cleaned', t => {
t.matchSnapshot(errorMessage(Object.assign(new Error('cmd err'), {
cmd: 'some command',
signal: 'SIGYOLO',
args: ['a', 'r', 'g', 's', 'https://evil:password@npmjs.org'],
stdout: 'stdout',
stderr: 'stderr',
}), npm))
t.end()
})

t.test('eacces/eperm', t => {
const runTest = (windows, loaded, cachePath, cacheDest) => t => {
if (windows)
Expand Down