mirror of
https://github.com/zhigang1992/replace-in-file.git
synced 2026-06-15 02:29:12 +08:00
- Drop deprecated API - Drop support for Node 4 and 5 - Refactor and clean up code base - Leverage destructuring - Option to disable globs (#33) - Update readme
23 lines
414 B
JavaScript
23 lines
414 B
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Dependencies
|
|
*/
|
|
const chalk = require('chalk');
|
|
|
|
/**
|
|
* Error handler
|
|
*/
|
|
module.exports = function errorHandler(error, message = '', exitCode = 1) {
|
|
if (typeof error === 'string') {
|
|
message = error;
|
|
error = null;
|
|
}
|
|
message = message || 'Error making replacements';
|
|
console.error(chalk.red(message));
|
|
if (error) {
|
|
console.error(error);
|
|
}
|
|
process.exit(exitCode);
|
|
};
|