kopia lustrzana https://github.com/badgen/badgen.net
feat: start github live badges (#15)
* feat: start github live badges Signed-off-by: Charlike Mike Reagent <olsten.larck@gmail.com> * fix: sort keys Signed-off-by: Charlike Mike Reagent <olsten.larck@gmail.com> * fix: remove sort-keys rule Signed-off-by: Charlike Mike Reagent <olsten.larck@gmail.com> * fix: address comments - orange color on prerelease Signed-off-by: Charlike Mike Reagent <olsten.larck@gmail.com>pull/23/head
rodzic
2c2fca4074
commit
3f55c30137
|
@ -1,10 +1,11 @@
|
|||
module.exports = {
|
||||
'codecov': require('./codecov.js'),
|
||||
'appveyor': require('./appveyor.js'),
|
||||
'chrome-web-store': require('./chrome-web-store.js'),
|
||||
'circleci': require('./circleci.js'),
|
||||
'codecov': require('./codecov.js'),
|
||||
'crates': require('./crates.js'),
|
||||
'david': require('./david.js'),
|
||||
'github': require('./github.js'),
|
||||
'homebrew': require('./homebrew.js'),
|
||||
'npm': require('./npm.js'),
|
||||
'travis': require('./travis.js')
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
const axios = require('../axios.js')
|
||||
|
||||
// https://developer.github.com/v3/repos/
|
||||
|
||||
module.exports = async function (method, ...args) {
|
||||
switch (method) {
|
||||
case 'release':
|
||||
return release('release', args)
|
||||
case 'tag':
|
||||
return release('tag', args)
|
||||
default:
|
||||
return {
|
||||
subject: 'github',
|
||||
status: 'unknown',
|
||||
color: 'grey'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function release (topic, args) {
|
||||
const endpoint = `https://api.github.com/repos/${args.join('/')}/${topic}s`
|
||||
const meta = await axios.get(endpoint).then(res => res.data)
|
||||
|
||||
const [first] = meta
|
||||
|
||||
return {
|
||||
subject: topic,
|
||||
status: first.name || first.tag_name || 'unknown',
|
||||
color: first.prerelease === true ? 'orange' : 'blue'
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue