refator: use error-first-handler
This commit is contained in:
@@ -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
@@ -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
@@ -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
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user