UNPKG

1.08 kBJavaScriptView Raw
1const cli = require('heroku-cli-util')
2const co = require('co')
3const shellescape = require('shell-escape')
4const api = require('../../lib/heroku-api')
5
6function* run (context, heroku) {
7 const coupling = yield api.pipelineCoupling(heroku, context.app)
8 const config = yield api.configVars(heroku, coupling.pipeline.id)
9
10 if (context.flags.shell) {
11 Object.keys(config).forEach((key) => {
12 cli.log(`${key}=${shellescape([config[key]])}`)
13 })
14 } else if (context.flags.json) {
15 cli.styledJSON(config)
16 } else {
17 cli.styledHeader(`${coupling.pipeline.name} test config vars`)
18 cli.styledObject(Object.keys(config).reduce((memo, key) => {
19 memo[cli.color.green(key)] = config[key]
20 return memo
21 }, {}))
22 }
23}
24
25module.exports = {
26 topic: 'ci',
27 command: 'config',
28 needsApp: true,
29 needsAuth: true,
30 description: 'display CI config vars',
31 flags: [
32 {name: 'shell', char: 's', description: 'output config vars in shell format'},
33 {name: 'json', description: 'output config vars in json format'}
34 ],
35 run: cli.command(co.wrap(run))
36}