From 07522c0c19335ac5c3d0c8848b0c3802e1a4fd8b Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 11 Mar 2023 16:30:22 -0500 Subject: [PATCH] Update debug to add a key, when set exit the app on error .env key "EXIT_ON_ERROR" --- utilities/debugBuilder.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utilities/debugBuilder.js b/utilities/debugBuilder.js index cd24590..65be4d9 100644 --- a/utilities/debugBuilder.js +++ b/utilities/debugBuilder.js @@ -1,5 +1,7 @@ // Debug const debug = require('debug'); +// Read .env file to process.env +require('dotenv').config(); /** * Create the different logging methods for a function @@ -13,6 +15,10 @@ exports.DebugBuilder = class DebugBuilder { this.DEBUG = debug(`${appName}:${fileName}:DEBUG`); this.VERBOSE = debug(`${appName}:${fileName}:VERBOSE`); this.WARN = debug(`${appName}:${fileName}:WARNING`); - this.ERROR = debug(`${appName}:${fileName}:ERROR`).then(process.exit()); + this.ERROR = (...messageParts) => { + const error = debug(`${appName}:${fileName}:ERROR`); + error(messageParts); + if (process.env.EXIT_ON_ERROR) process.exit(); + } } } \ No newline at end of file