fix(cli): automatically run in debug mode locally

BREAKING CHANGE: The `--no-ci` flag is gone. If you want to run `semantic-release` locally now you have to explicitly run `semantic-release pre --debug=false` && `semantic-release post --debug=false`
This commit is contained in:
Stephan Bönnemann 2015-02-08 10:46:42 +01:00
parent d94c6b76d3
commit e0fc4840de
2 changed files with 25 additions and 33 deletions

View File

@ -14,7 +14,9 @@ var argv = minimist(process.argv.slice(2), {
t: 'token', t: 'token',
g: 'github-url' g: 'github-url'
}, },
booleans: ['debug'],
default: { default: {
debug: !process.env.CI,
token: process.env.GH_TOKEN || process.env.TOKEN || process.env.GITHUB_TOKEN, token: process.env.GH_TOKEN || process.env.TOKEN || process.env.GITHUB_TOKEN,
'github-url': process.env.GH_URL 'github-url': process.env.GH_URL
} }
@ -31,46 +33,37 @@ if (~argv._.indexOf('pre')) {
// in this case we abort the command and do nothing. // in this case we abort the command and do nothing.
if (isAbbrev(npmArgv, 'install')) process.exit(0) if (isAbbrev(npmArgv, 'install')) process.exit(0)
return confirmCI(function () { if (argv.debug) console.log('This is a dry run')
console.log('Determining new version')
var publish = false console.log('Determining new version')
if (isAbbrev(npmArgv, 'publish')) publish = true
require('../src/pre')(argv, efh(function (result) { var publish = false
if (!result) { if (isAbbrev(npmArgv, 'publish')) publish = true
console.log('Nothing changed. Not publishing.')
process.exit(1)
}
console.log('Publishing v' + result) require('../src/pre')(argv, efh(function (result) {
if (!publish) process.exit(0) if (!result) {
console.log('Nothing changed. Not publishing.')
process.exit(1)
}
require('../src/restart')(efh(function () { console.log('Publishing v' + result)
process.exit(1) if (!publish) process.exit(0)
}))
if (argv.debug) process.exit(1)
require('../src/restart')(efh(function () {
process.exit(1)
})) }))
}) }))
} }
if (~argv._.indexOf('post')) { if (~argv._.indexOf('post')) {
return confirmCI(function () { require('../src/post')(argv, efh(function () {
require('../src/post')(argv, efh(function () { // see src/restart.js
// see src/restart.js if (npmArgv['semantic-release-rerun']) {
if (npmArgv['semantic-release-rerun']) { console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.') }
} }))
}))
})
}
function confirmCI (cb) {
if (process.env.CI || argv.ci === false) return cb(null, true)
confirm('Not running in a CI enviroment. Are you sure you want to run this hook?', function (ok) {
if (!ok) process.exit(1)
cb(null, ok)
})
} }
function isAbbrev (argv, command) { function isAbbrev (argv, command) {

View File

@ -9,7 +9,6 @@
}, },
"dependencies": { "dependencies": {
"abbrev": "^1.0.5", "abbrev": "^1.0.5",
"confirm-simple": "^1.0.3",
"conventional-changelog": "0.0.11", "conventional-changelog": "0.0.11",
"error-first-handler": "^1.0.1", "error-first-handler": "^1.0.1",
"git-node": "^0.1.1", "git-node": "^0.1.1",