Skip to content

Commit

Permalink
fix: don't break up log message across lines
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Mar 30, 2023
1 parent 1435fcf commit 829503b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
6 changes: 2 additions & 4 deletions lib/utils/exit-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ const log = require('./log-shim.js')
const errorMessage = require('./error-message.js')
const replaceInfo = require('./replace-info.js')

const indent = (val) => Array.isArray(val) ? val.map(v => indent(v)) : ` ${val}`

let npm = null // set by the cli
let exitHandlerCalled = false
let showLogFileError = false
Expand Down Expand Up @@ -73,15 +71,15 @@ process.on('exit', code => {
const message = []

if (timingFile) {
message.push('Timing info written to:', indent(timingFile))
message.push(`Timing info written to: ${timingFile}`)
} else if (timing) {
message.push(
`The timing file was not written due to an error writing to the directory: ${timingDir}`
)
}

if (logFiles.length) {
message.push('A complete log of this run can be found in:', ...indent(logFiles))
message.push(`A complete log of this run can be found in: ${logFiles}`)
} else if (logsMax <= 0) {
// user specified no log file
message.push(`Log files were not written due to the config logs-max=${logsMax}`)
Expand Down
3 changes: 1 addition & 2 deletions smoke-tests/tap-snapshots/test/index.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ npm ERR! aliases: clean-install, ic, install-clean, isntall-clean
npm ERR!
npm ERR! Run "npm help ci" for more info
npm ERR! A complete log of this run can be found in:
npm ERR! A complete log of this run can be found in: {NPM}/{TESTDIR}/cache/_logs/{LOG}
`

exports[`test/index.js TAP basic npm diff > should have expected diff output 1`] = `
Expand Down
2 changes: 1 addition & 1 deletion smoke-tests/test/fixtures/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = async (t, { testdir = {}, debug } = {}) => {
.replace(/\r\n/g, '\n')
.replace(/ \(in a browser\)/g, '')
.replace(/^npm@.* /gm, 'npm ')
.replace(/^.*debug-[0-9]+.log$/gm, '')
.replace(/[0-9TZ_-]*debug-[0-9]+.log$/gm, '{LOG}')
.replace(/in \d+[ms]+$/gm, 'in {TIME}')
}
const log = (...a) => debugLog(cleanOutput(a.join(' ')))
Expand Down
6 changes: 2 additions & 4 deletions tap-snapshots/test/lib/utils/exit-handler.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ XX error ERR DETAIL Unknown error
XX verbose exit 1
XX timing npm Completed in {TIME}ms
XX verbose code 1
XX error A complete log of this run can be found in:
XX error {CWD}/cache/_logs/{DATE}-debug-0.log
XX error A complete log of this run can be found in: {CWD}/cache/_logs/{DATE}-debug-0.log
`

exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and debug file > logs 1`] = `
Expand Down Expand Up @@ -63,6 +62,5 @@ error ERR DETAIL Unknown error
verbose exit 1
timing npm Completed in {TIME}ms
verbose code 1
error A complete log of this run can be found in:
{CWD}/cache/_logs/{DATE}-debug-0.log
error A complete log of this run can be found in: {CWD}/cache/_logs/{DATE}-debug-0.log
`

0 comments on commit 829503b

Please sign in to comment.