semantic-release/lib/version.js
2015-02-02 04:13:21 +01:00

19 lines
456 B
JavaScript

'use strict'
var exec = require('child_process').exec
var unlink = require('fs').unlinkSync
module.exports = function (pkg, cb) {
if (!pkg.name) return cb('Package must have a name')
exec('npm show ' + pkg.name + ' version', function(err, stdout, stderr) {
if (err) unlink('./npm-debug.log')
if (err && /is not in the npm registry/m.test(stderr)) return cb(null, null, true)
if (err) return cb(err)
cb(null, stdout.trim())
})
}