Skip to content

Commit

Permalink
Update version script to skip beta releases in changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Mar 21, 2017
1 parent 63f1686 commit 3e2283e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"main": "index.js",
"scripts": {
"changelog": "changelog-maker --filter-release -- wyze eslint-config-wyze",
"changelog": "changelog-maker --filter-release",
"lint": "eslint rules *.js",
"prelint": "npm link && npm link eslint-config-wyze",
"pretest": "npm run lint",
Expand Down
30 changes: 28 additions & 2 deletions scripts/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,34 @@ const getVersionAndUrl =
return { url, version }
}

// get previous version from changelog
const getPreviousVersion = ({ url, version }) => {
const file = 'changelog.md'
const changelog = readFile(file).toString().split('\n')
const regex = /\[(v\d+\.\d+\.\d+)\]/
const previous = changelog
.filter(change => regex.test(change))
.shift()
.match(/\[(v\d+\.\d+\.\d+)\]/)
.slice(1, 2)
.pop()

return { previous, url, version }
}

// npm run changelog (and grab output)
const getChanges = ({ url, version }) => {
const { stdout } = execa.sync('npm', [ 'run', 'changelog', '--silent' ])
const getChanges = ({ previous, url, version }) => {
const args = [
'run',
'changelog',
'--silent',
'--',
'--start-ref',
previous,
'wyze',
'eslint-config-wyze',
]
const { stdout } = execa.sync('npm', args)
const changes = stdout.trim().split(' \n')
// Filter beta releases because `changelog-maker` doesn't
.filter(msg => !isBeta(msg))
Expand Down Expand Up @@ -78,6 +103,7 @@ const runGitAdd = () => {

readPkg()
.then(getVersionAndUrl)
.then(getPreviousVersion)
.then(getChanges)
.then(updateChangelog)
.then(updateReadme)
Expand Down

0 comments on commit 3e2283e

Please sign in to comment.