mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-22 10:22:31 +01:00
add postversion script
https://github.com/mifi/lossless-cut/pull/987#issuecomment-1014246807
This commit is contained in:
parent
8956a52cc9
commit
425bf6f5de
@ -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
19
script/postversion.mjs
Normal 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));
|
Loading…
Reference in New Issue
Block a user