@storm-software/config-tools
Version:
A package containing various utilities to support custom workspace configurations and environment management for Storm Software projects, including configuration file handling, environment variable management, and logging utilities.
56 lines (53 loc) • 1.47 kB
JavaScript
import {
writeError,
writeFatal,
writeSuccess,
writeTrace
} from "./chunk-SMVSQFZ3.js";
// src/utilities/process-handler.ts
var exitWithError = (config) => {
writeFatal("Exiting script with an error status...", config);
process.exit(1);
};
var exitWithSuccess = (config) => {
writeSuccess("Script completed successfully. Exiting...", config);
process.exit(0);
};
var handleProcess = (config) => {
writeTrace(
`Using the following arguments to process the script: ${process.argv.join(", ")}`,
config
);
process.on("unhandledRejection", (error) => {
writeError(
`An Unhandled Rejection occurred while running the program: ${error}`,
config
);
exitWithError(config);
});
process.on("uncaughtException", (error) => {
writeError(
`An Uncaught Exception occurred while running the program: ${error.message}
Stacktrace: ${error.stack}`,
config
);
exitWithError(config);
});
process.on("SIGTERM", (signal) => {
writeError(`The program terminated with signal code: ${signal}`, config);
exitWithError(config);
});
process.on("SIGINT", (signal) => {
writeError(`The program terminated with signal code: ${signal}`, config);
exitWithError(config);
});
process.on("SIGHUP", (signal) => {
writeError(`The program terminated with signal code: ${signal}`, config);
exitWithError(config);
});
};
export {
exitWithError,
exitWithSuccess,
handleProcess
};