blob: e06c00db3363d463238aeb4b9ad77c74ae6c571a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
const { promisify } = require('util')
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])
readFile(changelogPath)
.then(async (changeBuffer) => {
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)
return newData.version
})
.then((version) => console.log(`Bumped ${bumpType} to version ${version}`))
.catch(console.error)
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
}
|