X Tutup
Skip to content

Commit 2ac6772

Browse files
authored
chore: fix pre passing to atom.rc (electron#16311)
* chore: fix pre passing to versionH * preTypes => preType
1 parent ff1c90b commit 2ac6772

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

script/bump-version.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ const minimist = require('minimist')
1212
const writeFile = promisify(fs.writeFile)
1313
const readFile = promisify(fs.readFile)
1414

15+
const preType = {
16+
NONE: 'none',
17+
PARTIAL: 'partial',
18+
FULL: 'full'
19+
}
20+
1521
function parseCommandLine () {
1622
let help
1723
const opts = minimist(process.argv.slice(2), {
@@ -164,8 +170,8 @@ async function updateWinRC (components) {
164170
const arr = data.split('\n')
165171
arr.forEach((line, idx) => {
166172
if (line.includes('FILEVERSION')) {
167-
arr[idx] = ` FILEVERSION ${utils.makeVersion(components, ',', true)}`
168-
arr[idx + 1] = ` PRODUCTVERSION ${utils.makeVersion(components, ',', true)}`
173+
arr[idx] = ` FILEVERSION ${utils.makeVersion(components, ',', preType.PARTIAL)}`
174+
arr[idx + 1] = ` PRODUCTVERSION ${utils.makeVersion(components, ',', preType.PARTIAL)}`
169175
} else if (line.includes('FileVersion')) {
170176
arr[idx] = ` VALUE "FileVersion", "${utils.makeVersion(components, '.')}"`
171177
arr[idx + 5] = ` VALUE "ProductVersion", "${utils.makeVersion(components, '.')}"`

script/lib/version-utils.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const { promisify } = require('util')
88
const readFile = promisify(fs.readFile)
99
const gitDir = path.resolve(__dirname, '..', '..')
1010

11+
const preType = {
12+
NONE: 'none',
13+
PARTIAL: 'partial',
14+
FULL: 'full'
15+
}
16+
1117
const getCurrentDate = () => {
1218
const d = new Date()
1319
const dd = `${d.getDate()}`.padStart(2, '0')
@@ -23,9 +29,11 @@ const isStable = v => {
2329
return !!(parsed && parsed.prerelease.length === 0)
2430
}
2531

26-
const makeVersion = (components, delim, withPre = false) => {
32+
const makeVersion = (components, delim, pre = preType.NONE) => {
2733
let version = [components.major, components.minor, components.patch].join(delim)
28-
if (withPre) {
34+
if (pre === preType.PARTIAL) {
35+
version += `${delim}${components.pre[1]}`
36+
} else if (pre === preType.FULL) {
2937
version += `-${components.pre[0]}${delim}${components.pre[1]}`
3038
}
3139
return version

0 commit comments

Comments
 (0)
X Tutup