2019-12-03 23:14:00 +01:00
|
|
|
/*
|
2020-04-14 01:10:19 +02:00
|
|
|
* ACHTUNG: this file is a hack used to load "settings.json.docker" instead of
|
|
|
|
* "settings.json", since in its present form the Settings module does
|
|
|
|
* not allow it.
|
|
|
|
* This is a remnant of an analogous file that was placed in
|
|
|
|
* <basedir>/tests/backend/loadSettings.js
|
2019-12-03 23:14:00 +01:00
|
|
|
*
|
2020-04-14 01:10:19 +02:00
|
|
|
* TODO: modify the Settings module:
|
|
|
|
* 1) no side effects on module load
|
|
|
|
* 2) write a factory method that loads a configuration file (taking the
|
|
|
|
* file name from the command line, a function argument, or falling
|
|
|
|
* back to a default)
|
2019-12-03 23:14:00 +01:00
|
|
|
*/
|
|
|
|
|
2020-11-23 19:21:51 +01:00
|
|
|
const jsonminify = require(`${__dirname}/../../src/node_modules/jsonminify`);
|
2019-12-03 23:14:00 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
|
2020-11-23 19:21:51 +01:00
|
|
|
function loadSettings() {
|
|
|
|
let settingsStr = fs.readFileSync(`${__dirname}/../../settings.json.docker`).toString();
|
2019-12-03 23:14:00 +01:00
|
|
|
// try to parse the settings
|
|
|
|
try {
|
2020-11-23 19:21:51 +01:00
|
|
|
if (settingsStr) {
|
|
|
|
settingsStr = jsonminify(settingsStr).replace(',]', ']').replace(',}', '}');
|
|
|
|
const settings = JSON.parse(settingsStr);
|
2019-12-03 23:14:00 +01:00
|
|
|
|
|
|
|
// custom settings for running in a container
|
|
|
|
settings.ip = 'localhost';
|
|
|
|
settings.port = '9001';
|
|
|
|
|
|
|
|
return settings;
|
|
|
|
}
|
2020-11-23 19:21:51 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.error('whoops something is bad with settings');
|
2019-12-03 23:14:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.loadSettings = loadSettings;
|