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
+9 -12
View File
@@ -8,6 +8,8 @@ var GitHubApi = require('github')
var parseSlug = require('parse-github-repo-url')
var parseUrl = require('github-url-from-git')
var efh = require('../lib/error').efh
var github = new GitHubApi({
version: '3.0.0'
})
@@ -16,18 +18,14 @@ module.exports = function (options, cb) {
var pkg = JSON.parse(readFile('./package.json'))
var repository = pkg.repository ? pkg.repository.url : null
if (!repository) return cb('Package must have a repository')
if (!repository) return cb(new Error('Package must have a repository'))
changelog({
version: pkg.version,
repository: parseUrl(repository),
file: false
}, function(err, log) {
if (err) return cb(err)
exec('git rev-parse HEAD', function(err, hash) {
if (err) return cb(err)
}, efh(cb)(function (log) {
exec('git rev-parse HEAD', efh(cb)(function (hash) {
var ghRepo = parseSlug(repository)
var release = {
owner: ghRepo[0],
@@ -43,10 +41,9 @@ module.exports = function (options, cb) {
token: options.token
})
github.releases.createRelease(release, function(err) {
if (err) return cb(err)
github.releases.createRelease(release, efh(cb)(function () {
cb(null, true)
})
})
})
}))
}))
}))
}