Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-07-20 17:53:08 +0300
committerGar <gar+gh@danger.computer>2021-07-22 16:57:20 +0300
commit009ad1e683aa061d7e5c78b9362b0bd1b14ee643 (patch)
tree4818bd448cbca67ad3427467f094f3334f48e3cb /test/lib/utils/exit-handler.js
parent1fe1c9b74ea3c3d5bb5b3696b954422b9b55dd91 (diff)
fix(exit-handler): always warn if not called
If the exit handler wasn't called it is always a problem, even if there is no exit code. PR-URL: https://github.com/npm/cli/pull/3561 Credit: @wraithgar Close: #3561 Reviewed-by: @lukekarrys
Diffstat (limited to 'test/lib/utils/exit-handler.js')
-rw-r--r--test/lib/utils/exit-handler.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/test/lib/utils/exit-handler.js b/test/lib/utils/exit-handler.js
index 981ac9a32..c88a1aef6 100644
--- a/test/lib/utils/exit-handler.js
+++ b/test/lib/utils/exit-handler.js
@@ -336,15 +336,14 @@ t.test('defaults to log error msg if stack is missing', (t) => {
t.end()
})
-t.test('exits cleanly when emitting exit event', (t) => {
- t.plan(1)
+t.test('exits uncleanly when only emitting exit event', (t) => {
+ t.plan(2)
npm.log.level = 'silent'
process.emit('exit')
- t.match(
- npm.log.record.find(r => r.level === 'info'),
- { prefix: 'ok', message: '' }
- )
+ const logData = fs.readFileSync(logFile, 'utf8')
+ t.match(logData, 'Exit handler never called!')
+ t.match(process.exitCode, 1, 'exitCode coerced to 1')
t.end()
})