Skip to content

Commit

Permalink
feat: -X --force-exit option
Browse files Browse the repository at this point in the history
  • Loading branch information
PopGoesTheWza committed Mar 17, 2021
1 parent 8c5d352 commit a65760c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {Conf} from './conf';
import {PROJECT_NAME} from './constants';
import {spinner, stopSpinner} from './utils';

let beforeExit = () => {};
let onExit = () => {};

// instantiate the config singleton (and loads environment variables as a side effect)
Expand Down Expand Up @@ -106,7 +107,14 @@ commander
* Display some debugging info upon exit.
*/
commander.option('-W, --why', `Display some debugging info upon exit.`).on('option:why', () => {
onExit = log;
beforeExit = log;
});

/**
* Display some debugging info upon exit.
*/
commander.option('-X, --force-exit', `Force process.exit().`).on('option:force-exit', () => {
onExit = process.exit;
});

/**
Expand Down Expand Up @@ -422,6 +430,8 @@ if (args.length === 0) {
console.error('Unknown error', error);
}
}
spinner.clear();
})();

beforeExit();
onExit();

0 comments on commit a65760c

Please sign in to comment.