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
+14
View File
@@ -0,0 +1,14 @@
'use strict'
var efh = require('error-first-handler')
module.exports = {
efh: efh,
standard: efh(function(err) {
console.log('Something went wrong:')
if (typeof err === 'string') return console.log(err)
if (err instanceof Error) return console.log(err.message)
if (err.message) return console.log(err.message)
console.log(err)
})
}
+6 -7
View File
@@ -2,13 +2,12 @@
var git = require('conventional-changelog/lib/git')
module.exports = function (cb) {
git.latestTag(function (err, from) {
if (err) return cb(err)
var efh = require('../error').efh
git.getCommits({from: from}, function (err, commits) {
if (err) return cb(err)
module.exports = function (cb) {
git.latestTag(efh(cb)(function (from) {
git.getCommits({from: from}, efh(cb)(function (commits) {
cb(null, commits)
})
})
}))
}))
}
+4 -5
View File
@@ -1,12 +1,11 @@
'use strict'
var commits = require('./commits')
var analyze = require('./analyze')
var commits = require('./commits')
var efh = require('../error').efh
module.exports = function (cb) {
commits(function (err, commits) {
if (err) return cb(err)
commits(efh(cb)(function (commits) {
cb(null, analyze(commits))
})
}))
}
+1 -1
View File
@@ -4,7 +4,7 @@ var exec = require('child_process').exec
var unlink = require('fs').unlinkSync
module.exports = function (pkg, cb) {
if (!pkg.name) return cb('Package must have a name')
if (!pkg.name) return cb(new Error('Package must have a name'))
exec('npm show ' + pkg.name + ' version', function(err, stdout, stderr) {
if (err) unlink('./npm-debug.log')