From a540c402a90c231897dbbc98ee2632b503d31de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Wed, 4 Feb 2015 18:56:31 +0100 Subject: [PATCH] fix(version): use $npm_config_registry variable to ensure the right registry BREAKING CHANGE: This breaks the usage of the `semantic-release` CLI outside of npm scripts. --- lib/version.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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) + })) }