From bf29fa81647a434bd0517cce24c740b779aa7080 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Tue, 27 Jul 2021 19:47:39 +0200 Subject: [PATCH] Always write hash on build. https://github.com/Koenkk/zigbee2mqtt/issues/8145 --- index.js | 18 ++++++++++++------ package.json | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 10ea0fb4c..d17cec612 100644 --- a/index.js +++ b/index.js @@ -32,6 +32,11 @@ async function currentHash() { }); } +async function writeHash() { + const hash = await currentHash(); + fs.writeFileSync(hashFile, hash); +} + async function build(reason) { return new Promise((resolve, reject) => { process.stdout.write(`Building Zigbee2MQTT... (${reason})`); @@ -42,8 +47,6 @@ async function build(reason) { reject(err); } else { process.stdout.write(', finished\n'); - const hash = await currentHash(); - fs.writeFileSync(hashFile, hash); resolve(); } }); @@ -102,7 +105,10 @@ async function handleQuit() { } } -process.on('SIGINT', handleQuit); -process.on('SIGTERM', handleQuit); - -start(); +if (process.argv.length === 3 && process.argv[2] === 'writehash') { + writeHash(); +} else { + process.on('SIGINT', handleQuit); + process.on('SIGTERM', handleQuit); + start(); +} diff --git a/package.json b/package.json index 3cd54b2ad..9b10c7ee4 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cc2531" ], "scripts": { - "build": "node_modules/.bin/tsc", + "build": "node_modules/.bin/tsc && node index.js writehash", "build-watch": "node_modules/.bin/tsc --watch", "eslint": "node_modules/.bin/eslint lib/ --max-warnings=0", "start": "node index.js",