Skip to content

Commit

Permalink
fix(npm-info): registry unexpectedly returned no json formatted error
Browse files Browse the repository at this point in the history
This only affected publishing of yet unreleased packages.
  • Loading branch information
boennemann committed Apr 3, 2015
1 parent d5a8cb1 commit f74f764
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/npm-info.js
Expand Up @@ -6,20 +6,21 @@ var efh = require('./error').efh

module.exports = function (pkgName, cb) {
request(process.env.npm_config_registry + pkgName, efh(cb)(function (response, body) {
var pkg = JSON.parse(body)

if (pkg.error && response.statusCode !== 404) return cb(pkg.error)

var res = {
version: '',
gitHead: '',
pkg: pkg
version: null,
gitHead: null,
pkg: null
}

if (response.statusCode === 404) return cb(null, res)
if (response.statusCode === 404 || !body) return cb(null, res)

var pkg = JSON.parse(body)

if (pkg.error && response.statusCode !== 404) return cb(pkg.error)

res.version = pkg['dist-tags'].latest
res.gitHead = pkg.versions[res.version].gitHead
res.pkg = pkg

cb(null, res)
}))
Expand Down

0 comments on commit f74f764

Please sign in to comment.