You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
924 B
JavaScript

'use strict';
const fs = require("fs");
module.exports = function loadConfiguration(configurationPath) {
if (configurationPath == null) {
console.error("You must specify a configuration file.");
process.exit(1);
}
let config = JSON.parse(fs.readFileSync(configurationPath));
if (config.metadata == null || config.metadata.from == null || config.metadata.to == null) {
console.error("Your configuration file must specify at least a sender (metadata.from) and a recipient (metadata.to).");
process.exit(1);
}
if (config.errorPath == null) {
console.error("Your configuration file must specify an errorPath.");
process.exit(1);
}
if (config.subjectFormat == null) {
config.subjectFormat = "UNHANDLED ERROR: $type - $message"
}
if (config.stackFilter == null) {
config.stackFilter = "*";
}
return config;
};