electron/script/generate-version-json.js
Samuel Attard 7201845894
refactor: auto generate electron_version.h from the version file (#18866)
* refactor: auto generate electron_version.h from the version file

* Update BUILD.gn

Co-Authored-By: Jeremy Apthorp <nornagon@nornagon.net>
2019-06-19 14:31:55 -07:00

28 lines
585 B
JavaScript

const fs = require('fs')
const path = require('path')
const semver = require('semver')
const outputPath = process.argv[2]
const currentVersion = fs.readFileSync(path.resolve(__dirname, '../ELECTRON_VERSION'), 'utf8').trim()
const parsed = semver.parse(currentVersion)
let prerelease = ''
if (parsed.prerelease && parsed.prerelease.length > 0) {
prerelease = parsed.prerelease.join('.')
}
const {
major,
minor,
patch
} = parsed
fs.writeFileSync(outputPath, JSON.stringify({
major,
minor,
patch,
prerelease,
has_prerelease: prerelease === '' ? 0 : 1
}, null, 2))