Merge pull request #4 from boennemann/refactor-exec

Refactor exec
This commit is contained in:
Stephan Bönnemann 2015-02-05 13:14:42 +01:00
commit 782c992755
3 changed files with 9 additions and 7 deletions

View File

@ -1,16 +1,16 @@
'use strict'
var exec = require('child_process').exec
var request = require('request')
var efh = require('./error').efh
module.exports = function (pkg, cb) {
if (!pkg.name) return cb(new Error('Package must have a name'))
exec('curl -s "' + process.env.npm_config_registry + pkg.name + '"', efh(cb)(function(stdout) {
var pkg = JSON.parse(stdout)
request(process.env.npm_config_registry + pkg.name, efh(cb)(function (response, body) {
var pkg = JSON.parse(body)
if (pkg.error) return cb(null, null, true)
if (response.statusCode === 404 || pkg.error) return cb(null, null, true)
cb(null, pkg['dist-tags'].latest)
}))

View File

@ -12,14 +12,16 @@
"confirm-simple": "^1.0.3",
"conventional-changelog": "0.0.11",
"error-first-handler": "^1.0.1",
"git-node": "^0.1.1",
"github": "^0.2.3",
"github-url-from-git": "^1.4.0",
"minimist": "^1.1.0",
"parse-github-repo-url": "^1.0.0",
"request": "^2.53.0",
"semver": "^4.2.0"
},
"devDependencies": {
"github-release-fake-server": "^1.1.1",
"github-release-fake-server": "^1.2.0",
"lodash.defaults": "^3.0.0",
"nano-uid": "^0.2.0",
"nixt": "^0.4.1",

View File

@ -1,10 +1,10 @@
'use strict'
var exec = require('child_process').exec
var readFile = require('fs').readFileSync
var url = require('url')
var changelog = require('conventional-changelog')
var git = require('git-node')
var GitHubApi = require('github')
var parseSlug = require('parse-github-repo-url')
var parseUrl = require('github-url-from-git')
@ -31,7 +31,7 @@ module.exports = function (options, cb) {
repository: parseUrl(repository),
file: false
}, efh(cb)(function (log) {
exec('git rev-parse HEAD', efh(cb)(function (hash) {
git.repo('./.git').loadAs('commit', 'HEAD', efh(cb)(function (commit, hash) {
var ghRepo = parseSlug(repository)
var release = {
owner: ghRepo[0],