Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 21, 2023
1 parent b7dfbe1 commit 55af0ed
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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.
*
Expand Down

0 comments on commit 55af0ed

Please sign in to comment.