specialist
Version:
A library that helps you write tiny, fast and beautiful CLI apps that can automatically check for updates.
19 lines (18 loc) • 525 B
JavaScript
/* IMPORT */
import process from 'node:process';
import color from 'tiny-colors';
/* MAIN */
// Little function modeled to have the same visual output as tiny-bin's "fail" function
// It targets either stdout or stderr automatically, based on the exit code
const exit = (message, code = 1) => {
const log = code === 0 ? console.log : console.error;
if (code === 0) {
log(message);
}
else {
log(`\n ${color.red(message)}\n`);
}
process.exit(code);
};
/* EXPORT */
export default exit;