diff --git a/lib/version.js b/lib/version.js index c3863377..c1047fbb 100644 --- a/lib/version.js +++ b/lib/version.js @@ -1,18 +1,17 @@ 'use strict' var exec = require('child_process').exec -var unlink = require('fs').unlinkSync + +var efh = require('./error').efh module.exports = function (pkg, cb) { 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') + exec('curl -s "' + process.env.npm_config_registry + pkg.name + '"', efh(cb)(function(stdout) { + var pkg = JSON.parse(stdout) - if (err && /is not in the npm registry/m.test(stderr)) return cb(null, null, true) + if (pkg.error) return cb(null, null, true) - if (err) return cb(err) - - cb(null, stdout.trim()) - }) + cb(null, pkg['dist-tags'].latest) + })) }