1 | const cli = require('heroku-cli-util')
|
2 | const co = require('co')
|
3 | const api = require('../../lib/heroku-api')
|
4 | const TestRun = require('../../lib/test-run')
|
5 | const Utils = require('../../lib/utils')
|
6 |
|
7 | function* run (context, heroku) {
|
8 | const pipeline = yield Utils.getPipeline(context, heroku)
|
9 | const lastRun = yield api.latestTestRun(heroku, pipeline.id)
|
10 |
|
11 | if (!lastRun) {
|
12 | return cli.error('No Heroku CI runs found for this pipeline.')
|
13 | }
|
14 |
|
15 | return yield TestRun.displayAndExit(pipeline, lastRun.number, { heroku })
|
16 | }
|
17 |
|
18 | module.exports = {
|
19 | topic: 'ci',
|
20 | command: 'last',
|
21 | wantsApp: true,
|
22 | needsAuth: true,
|
23 | description: 'get the results of the last run',
|
24 | flags: [
|
25 | {
|
26 | name: 'pipeline',
|
27 | char: 'p',
|
28 | hasValue: true,
|
29 | description: 'pipeline'
|
30 | }
|
31 | ],
|
32 | help: 'looks for the most recent run and returns the output of that run',
|
33 | run: cli.command(co.wrap(run))
|
34 | }
|