chore: convert bump script to js (#15820)

This commit is contained in:
Shelley Vohr 2018-12-06 11:00:10 -08:00 committed by GitHub
parent 2845267c18
commit 1b8c11121f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 378 additions and 323 deletions

View file

@ -3,7 +3,7 @@ const path = require('path')
const semver = require('semver')
const gitDir = path.resolve(__dirname, '..')
async function determineNextMajorForMaster () {
async function getLastMajorForMaster () {
let branchNames
const result = await GitProcess.exec(['branch', '-a', '--remote', '--list', 'origin/[0-9]-[0-9]-x'], gitDir)
if (result.exitCode === 0) {
@ -17,13 +17,7 @@ async function determineNextMajorForMaster () {
function getNextReleaseBranch (branches) {
const converted = branches.map(b => b.replace(/-/g, '.').replace('x', '0'))
const next = converted.reduce((v1, v2) => {
return semver.gt(v1, v2) ? v1 : v2
})
return parseInt(next.split('.')[0], 10)
return converted.reduce((v1, v2) => semver.gt(v1, v2) ? v1 : v2)
}
determineNextMajorForMaster().then(console.info).catch((err) => {
console.error(err)
process.exit(1)
})
module.exports = { getLastMajorForMaster }