Enforce code style. #45

This commit is contained in:
Koenkk
2018-05-17 17:20:46 +02:00
parent 5a95e2fc8c
commit c5cb60e998
16 changed files with 222 additions and 188 deletions
+3 -4
View File
@@ -4,12 +4,11 @@ let dataPath = null;
if (process.env.ZIGBEE2MQTT_DATA) {
dataPath = process.env.ZIGBEE2MQTT_DATA;
}
else {
} else {
dataPath = path.join(__dirname, '..', '..', 'data');
dataPath = path.normalize(dataPath);
}
module.exports = {
joinPath: (file) => path.join(dataPath, file)
}
joinPath: (file) => path.join(dataPath, file),
};
+3 -3
View File
@@ -17,9 +17,9 @@ const logger = new (winston.Logger)({
winston.config.colorize(options.level, options.level.toUpperCase()) + ' ' +
(options.message ? options.message : '') +
(options.meta && Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' );
}
})
]
},
}),
],
});
module.exports = logger;
+16 -16
View File
@@ -9,17 +9,17 @@ let yawn = read();
// Migrate configuration.
if (!yawn.json.advanced) {
// 1: Add advanced section to configuration.yaml
logger.info("Migrating configuration.yaml to version 1...");
yawn.yaml += "\n\n" +
"# Advanced configuration\n" +
"advanced:\n" +
" version: 1\n" +
" pan_id: 0x1a62\n";
logger.info('Migrating configuration.yaml to version 1...');
yawn.yaml += '\n\n' +
'# Advanced configuration\n' +
'advanced:\n' +
' version: 1\n' +
' pan_id: 0x1a62\n';
write_read();
writeRead();
}
function write_read() {
function writeRead() {
write();
yawn = read();
}
@@ -34,12 +34,12 @@ function read() {
function addDevice(id) {
if (!yawn.json.devices) {
const first = "\n" +
"# List of devices, automatically updates when new devices join, E.G.:\n" +
"# '0x00158d0001d8e1d2':\n" +
"# friendly_name: bedroom_switch # Friendly name to be used in MQTT topic\n" +
"# retain: true # Retain MQTT messages\n" +
"devices:\n" +
const first = '\n' +
'# List of devices, automatically updates when new devices join, E.G.:\n' +
`# '0x00158d0001d8e1d2':\n` +
'# friendly_name: bedroom_switch # Friendly name to be used in MQTT topic\n' +
'# retain: true # Retain MQTT messages\n' +
'devices:\n' +
` '${id}':\n` +
` friendly_name: '${id}'\n` +
` retain: false`;
@@ -51,7 +51,7 @@ function addDevice(id) {
yawn.json = {...yawn.json, devices: devices};
}
write_read();
writeRead();
}
module.exports = {
@@ -59,4 +59,4 @@ module.exports = {
write: () => write(),
getDevice: (id) => yawn.json.devices ? yawn.json.devices[id] : false,
addDevice: (id) => addDevice(id),
}
};