1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00

add postversion script

https://github.com/mifi/lossless-cut/pull/987#issuecomment-1014246807
This commit is contained in:
Mikael Finstad 2022-02-23 18:01:43 +08:00
parent 8956a52cc9
commit 425bf6f5de
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
2 changed files with 20 additions and 0 deletions

View File

@ -25,6 +25,7 @@
"pack-win": "electron-builder --win",
"prepack-win": "yarn build",
"postinstall": "patch-package && electron-builder install-app-deps",
"version": "node script/postversion.mjs && git add no.mifi.losslesscut.appdata.xml",
"pack-linux": "electron-builder --linux",
"prepack-linux": "yarn build",
"scan-i18n": "i18next-scanner --config i18next-scanner.config.js",

19
script/postversion.mjs Normal file
View File

@ -0,0 +1,19 @@
import { readFile, writeFile } from 'fs/promises';
import { XMLParser, XMLBuilder } from 'fast-xml-parser';
import moment from 'moment';
const xmlUrl = new URL('../no.mifi.losslesscut.appdata.xml', import.meta.url);
const xmlData = await readFile(xmlUrl);
const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url)));
const parser = new XMLParser({ alwaysCreateTextNode: true, ignoreAttributes: false, ignoreDeclaration: false });
const xml = parser.parse(xmlData);
// console.log(xml);
const { version } = packageJson;
xml.component.releases.release = [{ '@_version': version, '@_date': moment().format('YYYY-MM-DD') }, ...xml.component.releases.release];
const builder = new XMLBuilder({ format: true, ignoreAttributes: false, suppressEmptyNode: true });
await writeFile(xmlUrl, builder.build(xml));