Add support for version numbers and hash

This commit is contained in:
Marius Ciotlos authored and Marius Ciotlos committed 2018-06-15 14:02:40 +03:00
1 parent 3591f4f976
commit b6aabcca64
3 files changed
+15 -2

No files matched your search

+2 -1
View File
@@ -60,4 +60,5 @@ typings/
# data
data/database.db
data/config.json
data/log*.txt
data/log*.txt
data/hash.json
+10 -1
View File
@@ -5,7 +5,15 @@ const settings = require('./util/settings');
const zigbeeShepherdConverters = require('zigbee-shepherd-converters');
const homeassistant = require('./homeassistant');
const objectAssignDeep = require(`object-assign-deep`);
const data = require('./util/data');
const pjson = require('../package.json');
let version = `${pjson.version}`;
try {
const hjson = require(data.joinPath('hash.json')).id;
version = version + `:${hjson}`;
} catch (error) {
logger.debug('Error parsing git hash version', error);
}
const mqttConfigRegex = new RegExp(`${settings.get().mqtt.base_topic}/bridge/config/\\w+`, 'g');
const mqttDeviceRegex = new RegExp(`${settings.get().mqtt.base_topic}/[\\w\\s\\d]+/set`, 'g');
const mqttDevicePrefixRegex = new RegExp(`${settings.get().mqtt.base_topic}/[\\w\\s\\d]+/[\\w\\s\\d]+/set`, 'g');
@@ -39,6 +47,7 @@ class Controller {
}
start() {
logger.info(`Starting ... ${version}`);
this.zigbee.start(this.handleZigbeeMessage, (error) => {
if (error) {
logger.error('Failed to start');
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
echo "{\"id\": \"$(git rev-parse --short HEAD)\"}" > data/hash.json
echo "Hash version '$(git rev-parse --short HEAD)' generated successfully"