test: add specs to version bump utils (#16315)
This commit is contained in:
parent
668049a593
commit
434f1368a0
3 changed files with 42 additions and 9 deletions
|
@ -12,12 +12,6 @@ const minimist = require('minimist')
|
||||||
const writeFile = promisify(fs.writeFile)
|
const writeFile = promisify(fs.writeFile)
|
||||||
const readFile = promisify(fs.readFile)
|
const readFile = promisify(fs.readFile)
|
||||||
|
|
||||||
const preType = {
|
|
||||||
NONE: 'none',
|
|
||||||
PARTIAL: 'partial',
|
|
||||||
FULL: 'full'
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseCommandLine () {
|
function parseCommandLine () {
|
||||||
let help
|
let help
|
||||||
const opts = minimist(process.argv.slice(2), {
|
const opts = minimist(process.argv.slice(2), {
|
||||||
|
@ -170,8 +164,8 @@ async function updateWinRC (components) {
|
||||||
const arr = data.split('\n')
|
const arr = data.split('\n')
|
||||||
arr.forEach((line, idx) => {
|
arr.forEach((line, idx) => {
|
||||||
if (line.includes('FILEVERSION')) {
|
if (line.includes('FILEVERSION')) {
|
||||||
arr[idx] = ` FILEVERSION ${utils.makeVersion(components, ',', preType.PARTIAL)}`
|
arr[idx] = ` FILEVERSION ${utils.makeVersion(components, ',', utils.preType.PARTIAL)}`
|
||||||
arr[idx + 1] = ` PRODUCTVERSION ${utils.makeVersion(components, ',', preType.PARTIAL)}`
|
arr[idx + 1] = ` PRODUCTVERSION ${utils.makeVersion(components, ',', utils.preType.PARTIAL)}`
|
||||||
} else if (line.includes('FileVersion')) {
|
} else if (line.includes('FileVersion')) {
|
||||||
arr[idx] = ` VALUE "FileVersion", "${utils.makeVersion(components, '.')}"`
|
arr[idx] = ` VALUE "FileVersion", "${utils.makeVersion(components, '.')}"`
|
||||||
arr[idx + 5] = ` VALUE "ProductVersion", "${utils.makeVersion(components, '.')}"`
|
arr[idx + 5] = ` VALUE "ProductVersion", "${utils.makeVersion(components, '.')}"`
|
||||||
|
|
|
@ -77,5 +77,6 @@ module.exports = {
|
||||||
nextBeta,
|
nextBeta,
|
||||||
makeVersion,
|
makeVersion,
|
||||||
getElectronVersion,
|
getElectronVersion,
|
||||||
nextNightly
|
nextNightly,
|
||||||
|
preType
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,43 @@
|
||||||
const { expect } = require('chai')
|
const { expect } = require('chai')
|
||||||
const { nextVersion } = require('../script/bump-version')
|
const { nextVersion } = require('../script/bump-version')
|
||||||
|
const utils = require('../script/lib/version-utils')
|
||||||
|
|
||||||
|
describe('bump-version utils', () => {
|
||||||
|
it('makes a version with a period delimeter', () => {
|
||||||
|
const components = {
|
||||||
|
major: 2,
|
||||||
|
minor: 0,
|
||||||
|
patch: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const version = utils.makeVersion(components, '.')
|
||||||
|
expect(version).to.equal('2.0.0')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('makes a version with a period delimeter and a partial pre', () => {
|
||||||
|
const components = {
|
||||||
|
major: 2,
|
||||||
|
minor: 0,
|
||||||
|
patch: 0,
|
||||||
|
pre: [ 'nightly', 12345678 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
const version = utils.makeVersion(components, '.', utils.preType.PARTIAL)
|
||||||
|
expect(version).to.equal('2.0.0.12345678')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('makes a version with a period delimeter and a full pre', () => {
|
||||||
|
const components = {
|
||||||
|
major: 2,
|
||||||
|
minor: 0,
|
||||||
|
patch: 0,
|
||||||
|
pre: [ 'nightly', 12345678 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
const version = utils.makeVersion(components, '.', utils.preType.FULL)
|
||||||
|
expect(version).to.equal('2.0.0-nightly.12345678')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('bump-version script', () => {
|
describe('bump-version script', () => {
|
||||||
const nightlyPattern = /[0-9.]*(-nightly.(\d{4})(\d{2})(\d{2}))$/g
|
const nightlyPattern = /[0-9.]*(-nightly.(\d{4})(\d{2})(\d{2}))$/g
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue