actually do what last commit was meant to do

This commit is contained in:
zefie
2022-12-04 12:11:52 -05:00
parent c37cea3f66
commit abb01f4ce0

View File

@@ -16,6 +16,7 @@ class WTVShared {
parentDirectory = process.cwd() parentDirectory = process.cwd()
extend = require('util')._extend; extend = require('util')._extend;
debug = require('debug')('WTVShared') debug = require('debug')('WTVShared')
process = require('process');
shenanigans = null; shenanigans = null;
minisrv_config = []; minisrv_config = [];
@@ -446,17 +447,20 @@ class WTVShared {
if (this.fs.lstatSync(user_config_filename)) { if (this.fs.lstatSync(user_config_filename)) {
try { try {
var minisrv_user_config = this.parseJSON(this.fs.readFileSync(user_config_filename)); var minisrv_user_config = this.parseJSON(this.fs.readFileSync(user_config_filename));
} catch (e) { } catch (f) {
throw ("ERROR: Could not read user_config.json", e); console.error("ERROR: Could not read user_config.json", "\n\nReason:\n\n", f);
shutdown('SIGTERM'); this.process.exit(1);
} }
} else { } else {
var minisrv_user_config = {} var minisrv_user_config = {}
} }
return minisrv_user_config; return minisrv_user_config;
} catch (e) { } catch (e) {
if (minisrv_config.config.debug_flags) { if (!this.fs.existsSync(user_config_filename)) {
if (minisrv_config.config.debug_flags.debug) console.error(" * Notice: Could not find user configuration (user_config.json). Using default configuration."); console.error(" * Notice: Could not find user configuration (user_config.json). Using default configuration.");
} else {
console.error("ERROR: Could not read user_config.json", e);
this.process.exit(1);
} }
} }
} }
@@ -602,7 +606,7 @@ class WTVShared {
minisrv_config = integrateConfig(minisrv_config, minisrv_user_config) minisrv_config = integrateConfig(minisrv_config, minisrv_user_config)
} catch (e) { } catch (e) {
console.error("ERROR: Could not read user_config.json", e); console.error("ERROR: Could not read user_config.json", e);
shutdown('SIGTERM'); this.process.exit(1);
} }
} catch (e) { } catch (e) {
if (minisrv_config.config.debug_flags) { if (minisrv_config.config.debug_flags) {