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

37 lines
1.2 KiB

4 years ago
  1. /*
  2. * ACHTUNG: this file is a hack used to load "settings.json.docker" instead of
  3. * "settings.json", since in its present form the Settings module does
  4. * not allow it.
  5. * This is a remnant of an analogous file that was placed in
  6. * <basedir>/tests/backend/loadSettings.js
  7. *
  8. * TODO: modify the Settings module:
  9. * 1) no side effects on module load
  10. * 2) write a factory method that loads a configuration file (taking the
  11. * file name from the command line, a function argument, or falling
  12. * back to a default)
  13. */
  14. const jsonminify = require(`${__dirname}/../../src/node_modules/jsonminify`);
  15. const fs = require('fs');
  16. function loadSettings() {
  17. let settingsStr = fs.readFileSync(`${__dirname}/../../settings.json.docker`).toString();
  18. // try to parse the settings
  19. try {
  20. if (settingsStr) {
  21. settingsStr = jsonminify(settingsStr).replace(',]', ']').replace(',}', '}');
  22. const settings = JSON.parse(settingsStr);
  23. // custom settings for running in a container
  24. settings.ip = 'localhost';
  25. settings.port = '9001';
  26. return settings;
  27. }
  28. } catch (e) {
  29. console.error('whoops something is bad with settings');
  30. }
  31. }
  32. exports.loadSettings = loadSettings;