refator: use error-first-handler

This commit is contained in:
Stephan Bönnemann
2015-02-03 20:45:03 +01:00
parent 19fd15c1dc
commit 019aeeabe1
8 changed files with 51 additions and 55 deletions
+11 -23
View File
@@ -5,6 +5,8 @@ var abbrev = require('abbrev')
var confirm = require('confirm-simple')
var minimist = require('minimist')
var efh = require('../lib/error').standard
var argv = minimist(process.argv.slice(2), {
alias: {
d: 'debug',
@@ -21,8 +23,6 @@ var npmArgv = process.env.npm_config_argv ?
{_: []}
if (~argv._.indexOf('pre')) {
var publish = false
// see src/restart.js
if (npmArgv['semantic-release-rerun']) process.exit(0)
// the `prepublish` hook is also executed when the package is installed
@@ -30,47 +30,35 @@ if (~argv._.indexOf('pre')) {
if (isAbbrev(npmArgv, 'install')) process.exit(0)
return confirmCI(function () {
if (isAbbrev(npmArgv, 'publish')) publish = true
console.log('Determining new version')
require('../src/pre')(argv, function (err, result) {
if (err) {
console.log('Something went wrong.')
throw err
}
var publish = false
if (isAbbrev(npmArgv, 'publish')) publish = true
require('../src/pre')(argv, efh(function (result) {
if (!result) {
console.log('Nothing changed. Not publishing.')
process.exit(1)
}
console.log('Publishing v' + result)
if (publish) require('../src/restart')(function (err) {
if (err) {
console.log('Something went wrong.')
throw err
}
if (!publish) process.exit(0)
require('../src/restart')(efh(function () {
process.exit(1)
})
})
}))
}))
})
}
if (~argv._.indexOf('post')) {
return confirmCI(function () {
require('../src/post')(argv, function (err) {
if (err) {
console.log('Something went wrong.')
throw err
}
require('../src/post')(argv, efh(function () {
// see src/restart.js
if (npmArgv['semantic-release-rerun']) {
console.log('Everything is alright :) npm will now print an error message that you can safely ignore.')
}
})
}))
})
}