Created
February 8, 2023 13:55
-
-
Save scripting/8d02360d7c60e3fd3f92e0d6a5dff354 to your computer and use it in GitHub Desktop.
Code that reads config.json in daveappserver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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