Skip to content

Commit 8ab989b

Browse files
committed
fix(exitHandler): write code to logfile
This moves the logging of the exit code to before the logfile is written, when the exit handler was not called. This will ensure that the code shows up in the debug logs.
1 parent cf55fe0 commit 8ab989b

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

lib/utils/exit-handler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ process.on('exit', code => {
5858
if (!code)
5959
log.info('ok')
6060
else {
61+
log.verbose('code', code)
6162
if (!exitHandlerCalled) {
6263
log.error('', 'Exit handler never called!')
6364
console.error('')
@@ -66,7 +67,6 @@ process.on('exit', code => {
6667
// TODO this doesn't have an npm.config.loaded guard
6768
writeLogFile()
6869
}
69-
log.verbose('code', code)
7070
}
7171
// In timing mode we always write the log file
7272
if (npm.config && npm.config.loaded && npm.config.get('timing') && !wroteLogFile)

tap-snapshots/test/lib/utils/exit-handler.js.test.cjs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
*/
77
'use strict'
88
exports[`test/lib/utils/exit-handler.js TAP handles unknown error > should have expected log contents for unknown error 1`] = `
9-
0 verbose code 1
10-
1 error foo A complete log of this run can be found in:
11-
1 error foo {CWD}/test/lib/utils/tap-testdir-exit-handler/_logs/expecteddate-debug.log
12-
2 verbose stack Error: ERROR
13-
3 verbose cwd {CWD}
14-
4 verbose Foo 1.0.0
15-
5 verbose argv "/node" "{CWD}/test/lib/utils/exit-handler.js"
16-
6 verbose node v1.0.0
17-
7 verbose npm v1.0.0
18-
8 error foo code ERROR
9+
0 error foo A complete log of this run can be found in:
10+
0 error foo {CWD}/test/lib/utils/tap-testdir-exit-handler/_logs/expecteddate-debug.log
11+
1 verbose stack Error: ERROR
12+
2 verbose cwd {CWD}
13+
3 verbose Foo 1.0.0
14+
4 verbose argv "/node" "{CWD}/test/lib/utils/exit-handler.js"
15+
5 verbose node v1.0.0
16+
6 verbose npm v1.0.0
17+
7 error foo code ERROR
18+
8 error foo ERR ERROR
1919
9 error foo ERR ERROR
20-
10 error foo ERR ERROR
21-
11 verbose exit 1
20+
10 verbose exit 1
2221
2322
`

0 commit comments

Comments
 (0)