From 16cf9aee9b52f9539cae44d0bde256e08fc7542b Mon Sep 17 00:00:00 2001 From: Christoph Witzko Date: Tue, 3 Feb 2015 13:23:18 +0100 Subject: [PATCH] fix(cli): hooks work correctly w/abbrevd npm commands --- bin/semantic-release | 9 +++++++-- package.json | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/semantic-release b/bin/semantic-release index 8d0fcefb..e76cdb2c 100755 --- a/bin/semantic-release +++ b/bin/semantic-release @@ -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))) +} diff --git a/package.json b/package.json index 51f40474..6721360c 100644 --- a/package.json +++ b/package.json @@ -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",