Skip to content

Commit

Permalink
script: add script to generate the commit title for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlucas committed Apr 4, 2016
1 parent 046d058 commit 8d16a53
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions script/release-commit-title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

'use strict'

const semver = require('semver')
const utils = require('../lib/utils')
const args = process.argv.splice(2)

if (!args.length) {
const s = './script/release-commit-title.js'
console.error(`usage: ${s} <version>`)
console.error('or')
console.error(`usage: ${s} <patch|minor|major>`)
process.exit(1)
}

function getDate() {
const d = new Date()
const year = d.getFullYear()
const month = utils.pad(d.getMonth() + 1)
const day = utils.pad(d.getDate())
return `${year}-${month}-${day}`
}

const currentVersion = require('../package').version
const numbers = ['major', 'minor', 'patch']

const cmd = args.shift()
let version
if (~numbers.indexOf(cmd)) {
version = semver.inc(currentVersion, cmd)
} else {
version = cmd
}

if (!semver.valid(version)) {
console.error('Version is not valid %s', version)
process.exit(1)
}

version = version.replace('v', '')

console.log(`${getDate()} Version ${version} Release (Stable)`)

0 comments on commit 8d16a53

Please sign in to comment.