Check that the configuration file exists

Signed-off-by: Gérondal Thibault <contact@tycale.be>
This commit is contained in:
Gérondal Thibault
2018-12-29 20:00:13 +01:00
parent 2310302907
commit 97cf57d0a3

View File

@@ -15,8 +15,15 @@ function boolToString(istate) {
}
var connected = undefined;
var CONFIG = undefined;
const CONFIG = require("./config");
try {
CONFIG = require("./config");
} catch (e) {
console.error("Configuration file not found")
debugError(e)
process.exit(1)
}
const mqtt_client = mqtt.connect({
host: CONFIG.host,
@@ -204,5 +211,5 @@ var tester = new MQTT_Tester();
*/
function onExit() {
TuyaDevice.disconnectAll();
tester.destroy();
};
if(tester) tester.destroy();
};