feat(last-release): initial functionality
This commit is contained in:
parent
cce860ec03
commit
f62525ad7e
21
src/lib/last-release.js
Normal file
21
src/lib/last-release.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
const npmlog = require('npmlog')
|
||||||
|
const RegClient = require('npm-registry-client')
|
||||||
|
|
||||||
|
module.exports = function (pkg, npmConfig, cb) {
|
||||||
|
npmlog.level = npmConfig.loglevel || 'error'
|
||||||
|
const client = new RegClient({log: npmlog})
|
||||||
|
|
||||||
|
client.get(`${npmConfig.registry}/${pkg.name}`, {
|
||||||
|
auth: npmConfig.auth
|
||||||
|
}, (err, data) => {
|
||||||
|
if (err && err.statusCode === 404) return cb(null, {})
|
||||||
|
if (err) return cb(err)
|
||||||
|
|
||||||
|
const version = data['dist-tags'].latest
|
||||||
|
|
||||||
|
cb(null, {
|
||||||
|
version,
|
||||||
|
gitHead: data.versions[version].gitHead
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user