From 1aec48bef32b70d970c13064a7776e1437af8bab Mon Sep 17 00:00:00 2001 From: extracold1209 Date: Thu, 30 Jul 2020 17:22:15 +0900 Subject: [PATCH] =?UTF-8?q?[chore]=20app.asar=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=EC=9D=98=20=EC=B2=B4=ED=81=AC=EC=84=AC=EC=9D=84=20=EC=B6=94?= =?UTF-8?q?=EC=B6=9C=ED=95=98=EB=8A=94=20=ED=95=A8=EC=88=98=20=EB=94=B0?= =?UTF-8?q?=EB=A1=9C=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=EB=A1=9C=20?= =?UTF-8?q?=EC=B6=94=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 인자는 app.asar 가 존재하는 디렉토리경로 --- scripts/getChecksumFromAsar.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/getChecksumFromAsar.js diff --git a/scripts/getChecksumFromAsar.js b/scripts/getChecksumFromAsar.js new file mode 100644 index 000000000..ffbf2fab4 --- /dev/null +++ b/scripts/getChecksumFromAsar.js @@ -0,0 +1,31 @@ +const fs = require('fs'); +const path = require('path'); +const crypto = require('crypto'); + +module.exports = async(targetDirPath) => { + const asarFilePath = path.resolve(targetDirPath, 'app.asar'); + if (!fs.existsSync(asarFilePath)) { + console.warn('target file not found. checked path is ', asarFilePath); + return; + } + + try { + const digest = await new Promise((resolve, reject) => { + const checksum = crypto.createHash('sha1'); + const readStream = fs.createReadStream(asarFilePath); + readStream.on('data', (data) => { + checksum.update(data); + }); + readStream.on('end', () => { + resolve(checksum.digest('hex')); + }); + readStream.on('error', (e) => { + reject(e); + }); + }); + + return digest; + } catch (e) { + console.error('error occurred while read stream ', e); + } +};