'use strict';

var chalk = require('chalk');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

var chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);

class CustomError extends Error {
  get name() {
    return this.constructor.name;
  }
}
class ExitCodeError extends CustomError {
  code;
  constructor(code, command) {
    if (command) {
      super(`Command '${command}' exited with code ${code}`);
    } else {
      super(`Child exited with code ${code}`);
    }
    this.code = code;
  }
}
function exitWithError(error) {
  if (error instanceof ExitCodeError) {
    process.stderr.write(`
${chalk__default.default.red(error.message)}

`);
    process.exit(error.code);
  } else {
    process.stderr.write(`
${chalk__default.default.red(`${error}`)}

`);
    process.exit(1);
  }
}

exports.CustomError = CustomError;
exports.ExitCodeError = ExitCodeError;
exports.exitWithError = exitWithError;
//# sourceMappingURL=errors.cjs.js.map
