forked from OpenWebGAL/WebGAL_Terre
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnsis-version-sync.js
More file actions
21 lines (14 loc) · 812 Bytes
/
nsis-version-sync.js
File metadata and controls
21 lines (14 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const { readFile, writeFile } = require('fs/promises');
const {encode, decode} = require('iconv-lite');
(async () => {
const packageFile = await readFile('./package.json', { encoding: 'utf-8' });
const packageJson = JSON.parse(packageFile);
const version = packageJson.version;
if (!version) throw new Error('Get version failed.');
console.log("ver: ", version);
const nsisInstallerFilePath = './installer.nsi';
const nsisInstallerFileData = decode(await readFile(nsisInstallerFilePath), 'GB2312');
const newNsisInstallerFileData = encode(nsisInstallerFileData.replace(/^!define VERSION \".*\"/m, `!define VERSION "${version}"`), 'GB2312');
await writeFile(nsisInstallerFilePath, newNsisInstallerFileData);
console.log('已更新 nsis 配置文件版本号');
})();