r37r0m0d3l/consono

View on GitHub
src/utils/processExit.js

Summary

Maintainability
A
0 mins
Test Coverage
export default function processExit(code = 0) {
  if (code === false) {
    return;
  }
  if (code === true) {
    code = 0;
  }
  const exitCode = Number.parseInt(code.toString());
  if (!Number.isInteger(exitCode)) {
    return;
  }
  if (exitCode < 0) {
    return;
  }
  try {
    process.exit(exitCode);
  } catch (error) {
    //
  }
}