From 55af0ed560315d3fb551a68310b7742d8dc7eb62 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Mon, 21 Aug 2023 10:52:44 +0200 Subject: [PATCH] . --- lib/index.js | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/lib/index.js b/lib/index.js index 39e2290..723e7e4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -20,15 +20,6 @@ const ttyStream = new stream.Readable() // @ts-expect-error: TS doesn’t understand but that’s how Node streams work. ttyStream.isTTY = true -/** - * Exit, lazily, with the correct exit status code. - * - * @type {number | undefined} - */ -let exitCode - -process.on('exit', onexit) - // Handle uncaught errors, such as from unexpected async behaviour. process.on('uncaughtException', fail) @@ -116,7 +107,7 @@ export function args(options) { clean() fail(error) } else { - if (typeof code === 'number') exitCode = code + if (typeof code === 'number') process.exitCode = code if (state.args.watch && !watcher && context) { subscribe(context) @@ -166,13 +157,17 @@ export function args(options) { * Handle a SIGINT. */ function onsigint() { + console.log('n1') // Hide the `^C` in terminal. process.stderr.write('\n', noop) + console.log('n2') clean() + console.log('n3') // Do another process if `output` specified regeneration. if (output === true) { + console.log('n4') state.engine.output = output state.args.watch = false engine(state.engine, done) @@ -189,22 +184,10 @@ export function args(options) { * Nothing. */ function fail(error) { - exitCode = 1 + process.exitCode = 1 process.stderr.write(String(error.stack || error).trimEnd() + '\n', noop) } -/** - * Set `exitCode`. - * - * @returns {undefined} - * Nothing. - */ -function onexit() { - // eslint-disable-next-line unicorn/no-process-exit - process.exit(exitCode) - // . process.exitCode = exitCode -} - /** * Do nothing. *