electron/script/generate-version-json.js

30 lines
628 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
const semver = require('semver');
const fs = require('node:fs');
2020-03-20 20:28:31 +00:00
const outputPath = process.argv[2];
const currentVersion = process.argv[3];
2020-03-20 20:28:31 +00:00
const parsed = semver.parse(currentVersion);
2020-03-20 20:28:31 +00:00
let prerelease = '';
if (parsed.prerelease && parsed.prerelease.length > 0) {
2020-03-20 20:28:31 +00:00
prerelease = parsed.prerelease.join('.');
}
const {
major,
minor,
patch
2020-03-20 20:28:31 +00:00
} = parsed;
fs.writeFileSync(outputPath, JSON.stringify({
full_version: currentVersion,
major,
minor,
patch,
prerelease,
prerelease_number: prerelease ? parsed.prerelease[parsed.prerelease.length - 1] : '0',
has_prerelease: prerelease === '' ? 0 : 1
2020-03-20 20:28:31 +00:00
}, null, 2));