electron/script/generate-version-json.js

29 lines
595 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
const fs = require('fs');
const path = require('path');
const semver = require('semver');
2020-03-20 20:28:31 +00:00
const outputPath = process.argv[2];
2020-03-20 20:28:31 +00:00
const currentVersion = fs.readFileSync(path.resolve(__dirname, '../ELECTRON_VERSION'), 'utf8').trim();
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({
major,
minor,
patch,
prerelease,
has_prerelease: prerelease === '' ? 0 : 1
2020-03-20 20:28:31 +00:00
}, null, 2));