fix(cli): hooks work correctly w/abbrevd npm commands

This commit is contained in:
Christoph Witzko 2015-02-03 13:23:18 +01:00 committed by Stephan Bönnemann
parent f2c701ca1b
commit 16cf9aee9b
2 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env node
'use strict'
var abbrev = require('abbrev')
var confirm = require('confirm-simple')
var argv = require('minimist')(process.argv.slice(2), {
@ -24,10 +25,10 @@ if (~argv._.indexOf('pre')) {
if (~npmArgv.indexOf('--semantic-release-rerun')) process.exit(0)
// the `prepublish` hook is also executed when the package is installed
// in this case we abort the command and do nothing.
if (~npmArgv.indexOf('install')) process.exit(0)
if (isAbbrev(npmArgv, 'install')) process.exit(0)
return confirmCI(function () {
if (~npmArgv.indexOf('publish')) publish = true
if (isAbbrev(npmArgv, 'publish')) publish = true
console.log('Determining new version')
@ -79,3 +80,7 @@ function confirmCI (cb) {
cb(null, ok)
})
}
function isAbbrev (argv, command) {
return argv.some(Object.prototype.hasOwnProperty.bind(abbrev(command)))
}

View File

@ -8,6 +8,7 @@
"url": "https://github.com/boennemann/semantic-release/issues"
},
"dependencies": {
"abbrev": "^1.0.5",
"confirm-simple": "^1.0.3",
"conventional-changelog": "0.0.11",
"github": "^0.2.3",