1 | 'use strict'
|
2 |
|
3 | const co = require('co')
|
4 | const cli = require('heroku-cli-util')
|
5 | const helpers = require('../../lib/helpers')
|
6 | const Dyno = require('../../lib/dyno')
|
7 |
|
8 | function * run (context, heroku) {
|
9 | if (context.args.length < 2) throw new Error('Usage: heroku run:inside DYNO COMMAND\n\nExample: heroku run:inside web.1 bash')
|
10 | let opts = {
|
11 | heroku: heroku,
|
12 | app: context.app,
|
13 | dyno: context.args[0],
|
14 | command: helpers.buildCommand(context.args.slice(1)),
|
15 | 'exit-code': context.flags['exit-code'],
|
16 | env: context.flags.env,
|
17 | listen: context.flags.listen
|
18 | }
|
19 |
|
20 | let dyno = new Dyno(opts)
|
21 | yield dyno.start()
|
22 | }
|
23 |
|
24 | module.exports = {
|
25 | topic: 'run',
|
26 | command: 'inside',
|
27 | hidden: true,
|
28 | description: 'run a one-off process inside an existing heroku dyno',
|
29 | examples: `$ heroku run:inside web.1 bash
|
30 | Running bash on web.1.... up
|
31 | ~ $`,
|
32 | variableArgs: true,
|
33 | needsAuth: true,
|
34 | needsApp: true,
|
35 | flags: [
|
36 | { name: 'exit-code', description: 'passthrough the exit code of the remote command' },
|
37 | { name: 'env', description: "environment variables to set (use ';' to split multiple vars)", hasValue: true },
|
38 | { name: 'listen', description: 'listen on a local port', hasValue: false, hidden: true }
|
39 | ],
|
40 | run: cli.command(co.wrap(run))
|
41 | }
|