Browse Source

Merge pull request #9 from amio/travis-v2

Update travis badge, compat with .com & .org
test
Amio / 6 years ago
committed by GitHub
parent
commit
515737ff03
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      libs/index.md
  2. 3
      libs/live-fns/_index.js
  3. 32
      libs/live-fns/travis.js
  4. 2
      libs/redirect-fns/_index.js
  5. 1
      libs/redirect-fns/travis-org.js
  6. 3
      libs/redirect-fns/travis.js

1
libs/index.md

@ -63,6 +63,7 @@ Available color names:
| homebrew version | ![](/homebrew/v/fish) | [/homebrew/v/fish](/homebrew/v/fish)
| homebrew version | ![](/homebrew/v/cake) | [/homebrew/v/cake](/homebrew/v/cake)
| travis | ![](/travis/amio/micro-cors) | [/travis/amio/micro-cors](/travis/amio/micro-cors)
| travis | ![](/travis/styfle/packagephobia) | [/travis/styfle/packagephobia](/travis/styfle/packagephobia)
| circleci | ![](/circleci/github/amio/now-go) | [/circleci/github/amio/now-go](/circleci/github/amio/now-go)
| circleci (branch) | ![](/circleci/github/amio/now-go/master) | [/circleci/github/amio/now-go/master](/circleci/github/amio/now-go/master)
| appveyor ci | ![](/appveyor/ci/gruntjs/grunt) | [/appveyor/ci/gruntjs/grunt](/appveyor/ci/gruntjs/grunt)

3
libs/live-fns/_index.js

@ -5,5 +5,6 @@ module.exports = {
'crates': require('./crates.js'),
'david': require('./david.js'),
'homebrew': require('./homebrew.js'),
'npm': require('./npm.js')
'npm': require('./npm.js'),
'travis': require('./travis.js')
}

32
libs/live-fns/travis.js

@ -0,0 +1,32 @@
const axios = require('../axios.js')
module.exports = async function (user, repo, branch = 'master') {
const com = `https://api.travis-ci.com/${user}/${repo}.svg?branch=${branch}`
const org = `https://api.travis-ci.org/${user}/${repo}.svg?branch=${branch}`
const results = await Promise.all([
axios.get(com).then(res => res.data).catch(e => e),
axios.get(org).then(res => res.data).catch(e => e)
])
if (results[0].match('passing') || results[1].match('passing')) {
return {
subject: 'build',
status: 'passing',
color: 'green'
}
}
if (results[0].match('failed') || results[1].match('failed')) {
return {
subject: 'build',
status: 'failed',
color: 'red'
}
}
return {
subject: 'build',
status: 'unknown',
color: 'grey'
}
}

2
libs/redirect-fns/_index.js

@ -1,4 +1,4 @@
module.exports = {
'travis': require('./travis.js'),
// 'travis': require('./travis.js'),
'travis-org': require('./travis-org.js')
}

1
libs/redirect-fns/travis-org.js

@ -1,3 +1,4 @@
module.exports = function (...args) {
console.log('travis-org', args.join('/'))
return `https://api.travis-ci.org/${args.join('/')}.svg?branch=master`
}

3
libs/redirect-fns/travis.js

@ -1,3 +0,0 @@
module.exports = function (...args) {
return `https://api.travis-ci.com/${args.join('/')}.svg?branch=master`
}
Loading…
Cancel
Save