Work on copy config if needed.

This commit is contained in:
Scott Idem
2022-05-06 16:01:08 -04:00
parent f07aed2a02
commit 2a56129336

View File

@@ -57,13 +57,9 @@ exports.load_config = function () {
config_path = path.join(config_directory, 'config.json'); config_path = path.join(config_directory, 'config.json');
// Attempt to open the config file. The preferred location is based on the OS's config directory. // Attempt to open the config file. The preferred location is based on the OS's config directory.
// if (fs.existsSync(config_path)) { if (fs.existsSync(config_path)) {
// console.log(`Config path: ${config_path}`); console.log(`Config file (config.json) found under ${config_directory}`);
// console.log(`Config file (config.json) found under ${config_directory}`); } else if (!fs.existsSync(config_path) && fs.existsSync(default_config_path)) {
// } else
if (!fs.existsSync(config_path) && fs.existsSync(default_config_path)) {
fs.copyFileSync(default_config_path, config_path); fs.copyFileSync(default_config_path, config_path);
console.log('Default config file copied: '+config_directory); console.log('Default config file copied: '+config_directory);
@@ -82,7 +78,10 @@ exports.load_config = function () {
//console.log('Config file (config.json) not found under '+config_directory+'. Using config in CWD.'); //console.log('Config file (config.json) not found under '+config_directory+'. Using config in CWD.');
//config = JSON.parse(fs.readFileSync('config.json')); //config = JSON.parse(fs.readFileSync('config.json'));
} else { } else {
console.log('Unknown');
//close(); //close();
return false;
} }
config = JSON.parse(fs.readFileSync(config_path)); config = JSON.parse(fs.readFileSync(config_path));