mirror of
https://github.com/caprover/caprover
synced 2026-05-13 07:00:37 +00:00
40 lines
1.1 KiB
JavaScript
Executable File
40 lines
1.1 KiB
JavaScript
Executable File
var chalk = require("chalk");
|
|
function printMessage(message) {
|
|
console.log(message);
|
|
}
|
|
function printMessageAndExit(message) {
|
|
console.log(message);
|
|
process.exit(0);
|
|
}
|
|
function printGreenMessage(message, exit) {
|
|
if (exit === void 0) { exit = false; }
|
|
console.log("" + chalk.green(message));
|
|
exit && process.exit(0);
|
|
}
|
|
function printMagentaMessage(message, exit) {
|
|
if (exit === void 0) { exit = false; }
|
|
console.log("" + chalk.magenta(message));
|
|
exit && process.exit(0);
|
|
}
|
|
function printError(error, exit) {
|
|
if (exit === void 0) { exit = false; }
|
|
console.log("" + chalk.bold.red(error));
|
|
exit && process.exit(0);
|
|
}
|
|
function errorHandler(error) {
|
|
if (error.status) {
|
|
printError("\nError: " + error.status + "\nError: " + error.description, true);
|
|
}
|
|
else {
|
|
printError("\nError: " + error, true);
|
|
}
|
|
}
|
|
module.exports = {
|
|
printMessage: printMessage,
|
|
printMessageAndExit: printMessageAndExit,
|
|
printError: printError,
|
|
printGreenMessage: printGreenMessage,
|
|
printMagentaMessage: printMagentaMessage,
|
|
errorHandler: errorHandler
|
|
};
|