Skip to content

Instantly share code, notes, and snippets.

@scripting
Created February 8, 2023 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scripting/8d02360d7c60e3fd3f92e0d6a5dff354 to your computer and use it in GitHub Desktop.
Save scripting/8d02360d7c60e3fd3f92e0d6a5dff354 to your computer and use it in GitHub Desktop.
Code that reads config.json in daveappserver
function readConfigJson (callback) { //2/8/23 by DW
var configJs;
try {
configJs = require ("./config.js");
}
catch (err) { //try in the parent directory, assuming daveappserver is running in lib sub-directory
try {
configJs = require ("../config.js");
}
catch (err) { //fallback to reading config.json
readConfig (fnameConfig, config, true, callback);
return;
}
}
const jstruct = configJs;
for (var x in jstruct) {
config [x] = jstruct [x];
}
callback ();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment