Skip to content

Commit

Permalink
Add shelljs based release script
Browse files Browse the repository at this point in the history
  • Loading branch information
saintedlama committed Dec 9, 2015
1 parent 1248b5e commit 1f72797
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"concat-stream": "^1.5.0",
"geopkg": "^4.0.3",
"istanbul": "^0.4.1",
"shelljs": "^0.5.3",
"standard": "^5.4.1",
"tape": "^4.0.1"
},
Expand Down
36 changes: 36 additions & 0 deletions release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
var shell = require('shelljs');

if (exec('git status --porcelain').output != '') {
console.error('Git working directory not clean. Please commit all chances to release a new package to npm.')
process.exit(2);
}

var versionIncrement = process.argv[process.argv.length -1]
var versionIncrements = ['major', 'minor', 'patch']

if (versionIncrements.indexOf(versionIncrement) < 0) {
console.error('Usage: node release.js major|minor|patch')
process.exit(1)
}

exec('npm test')

exec('npm geopkg')
exec('git commit -m "Geotag package for release" package.json')

exec('npm version ' + versionIncrement)

exec('git push')
exec('git push --tags')
exec('npm publish')

function exec (cmd) {
var ret = shell.exec(cmd, { silent : true })

if (ret.code != 0) {
console.error(ret.output)
process.exit(1)
}

return ret
}

0 comments on commit 1f72797

Please sign in to comment.