Files
shields/services/appveyor/appveyor-build.service.js
Caleb Cartwright e626d64b4e convert some service classes to static props, run [ansible apm appveyor] (#5496)
* refactor(ansible): convert to static props

* refactor(apm): convert to static props

* refactor(appveyor): convert to static props

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-09-09 22:57:47 +00:00

37 lines
1.1 KiB
JavaScript

'use strict'
const { renderBuildStatusBadge } = require('../build-status')
const AppVeyorBase = require('./appveyor-base')
module.exports = class AppVeyorBuild extends AppVeyorBase {
static route = this.buildRoute('appveyor/build')
static examples = [
{
title: 'AppVeyor',
pattern: ':user/:repo',
namedParams: { user: 'gruntjs', repo: 'grunt' },
staticPreview: this.render({ status: 'success' }),
},
{
title: 'AppVeyor branch',
pattern: ':user/:repo/:branch',
namedParams: { user: 'gruntjs', repo: 'grunt', branch: 'master' },
staticPreview: this.render({ status: 'success' }),
},
]
static render({ status }) {
return renderBuildStatusBadge({ status })
}
async handle({ user, repo, branch }) {
const data = await this.fetch({ user, repo, branch })
if (!('build' in data)) {
// this project exists but no builds have been run on it yet
return this.constructor.render({ status: 'no builds found' })
}
return this.constructor.render({ status: data.build.status })
}
}