Handles when there is a last run and when there is not. It depends on
the call to test runs to return an ordered array of runs, created_at
desc.
This commit is contained in:
max beizer 2016-11-08 09:19:55 -06:00 коммит произвёл Andrew Appleton
Родитель 3863465ec0
Коммит d445aa6fbf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 74BD60891CAC329A
1 изменённых файлов: 28 добавлений и 0 удалений

28
commands/ci/last.js Normal file
Просмотреть файл

@ -0,0 +1,28 @@
const cli = require('heroku-cli-util')
const co = require('co')
const api = require('../../lib/heroku-api')
const TestRun = require('../../lib/test-run')
function* run (context, heroku) {
const coupling = yield api.pipelineCoupling(heroku, context.app)
const pipeline = coupling.pipeline
const pipelineID = pipeline.id
const runs = yield api.testRuns(heroku, pipelineID)
if (!runs[0]) {
return cli.error('No Heroku CI runs found for this pipeline.')
}
const runNum = runs[0]['number']
return yield TestRun.displayAndExit(pipeline, runNum, { heroku })
}
module.exports = {
topic: 'ci',
command: 'last',
needsApp: true,
needsAuth: true,
description: 'get the results of the last run',
help: 'looks for the most recent run and returns the output of that run',
run: cli.command(co.wrap(run))
}