A small 'live' web site which uses rest-api to represent a pseudo-termial-like interface.
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.

25 lines
603B

  1. const path = require('path');
  2. const fs = require('fs');
  3. const YAML = require('yaml');
  4. var CONFIG = null;
  5. var CONFIG_PATH = "";
  6. exports = {
  7. get: function(){
  8. if (arguments.length === 1 && typeof(arguments[0]) === 'string'){
  9. if (CONFIG_PATH !== arguments[0]){
  10. var cpath = path.normalize(arguments[0]);
  11. if (!path.isAbsolute(cpath))
  12. cpath = path.join(__dirname, cpath);
  13. try {
  14. CONFIG = YAML.parse(fs.readFileSync(cpath, 'utf8'));
  15. } catch (e) {
  16. console.log("ERROR: " + e.toString());
  17. }
  18. }
  19. }
  20. return CONFIG;
  21. }
  22. };