1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 04:37:13 +01:00
metamask-extension/development/run-version-bump.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

const promisify = require('pify')
const fs = require('fs')
const readFile = promisify(fs.readFile)
const writeFile = promisify(fs.writeFile)
const path = require('path')
const changelogPath = path.join(__dirname, '..', 'CHANGELOG.md')
const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json')
const manifest = require('../app/manifest.json')
const versionBump = require('./version-bump')
const bumpType = normalizeType(process.argv[2])
2018-03-02 23:33:29 +01:00
start().catch(console.error)
2018-07-03 00:49:33 +02:00
async function start () {
2018-03-02 23:33:29 +01:00
const changeBuffer = await readFile(changelogPath)
const changelog = changeBuffer.toString()
const newData = await versionBump(bumpType, changelog, manifest)
const manifestString = JSON.stringify(newData.manifest, null, 2)
await writeFile(changelogPath, newData.changelog)
await writeFile(manifestPath, manifestString)
2018-03-02 23:33:29 +01:00
console.log(`Bumped ${bumpType} to version ${newData.version}`)
}
function normalizeType (userInput) {
const err = new Error('First option must be a type (major, minor, or patch)')
if (!userInput || typeof userInput !== 'string') {
throw err
}
const lower = userInput.toLowerCase()
if (lower !== 'major' && lower !== 'minor' && lower !== 'patch') {
throw err
}
return lower
}