-
Notifications
You must be signed in to change notification settings - Fork 227
/
Copy pathrun.js
59 lines (54 loc) · 2.15 KB
/
run.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict'
let cli = require('heroku-cli-util')
let helpers = require('../lib/helpers')
let Dyno = require('../lib/dyno')
const { DynoSizeCompletion, ProcessTypeCompletion } = require('@heroku-cli/command/lib/completions')
const debug = require('debug')('heroku:run')
async function run (context, heroku) {
let opts = {
heroku: heroku,
app: context.app,
command: helpers.buildCommand(context.args),
size: context.flags.size,
type: context.flags.type,
notify: !context.flags['no-notify'],
'exit-code': context.flags['exit-code'],
env: context.flags.env,
'no-tty': context.flags['no-tty'],
attach: true,
listen: context.flags.listen
}
if (!opts.command) throw new Error('Usage: heroku run COMMAND\n\nExample: heroku run bash')
let dyno = new Dyno(opts)
try {
await dyno.start()
debug('done running')
} catch (err) {
debug(err)
if (err.exitCode) cli.exit(err.exitCode, err)
else throw err
}
}
module.exports = {
topic: 'run',
description: 'run a one-off process inside a heroku dyno',
help: 'Shows a notification if the dyno takes more than 20 seconds to start.',
examples: `$ heroku run bash
Running bash on app.... up, run.1
~ $
$ heroku run -s hobby -- myscript.sh -a arg1 -s arg2
Running myscript.sh -a arg1 -s arg2 on app.... up, run.1`,
variableArgs: true,
needsAuth: true,
needsApp: true,
flags: [
{ name: 'size', char: 's', description: 'dyno size', hasValue: true, completion: DynoSizeCompletion },
{ name: 'type', description: 'process type', hasValue: true, completion: ProcessTypeCompletion },
{ name: 'exit-code', char: 'x', description: 'passthrough the exit code of the remote command' },
{ name: 'env', char: 'e', description: "environment variables to set (use ';' to split multiple vars)", hasValue: true },
{ name: 'no-tty', description: 'force the command to not run in a tty', hasValue: false },
{ name: 'listen', description: 'listen on a local port', hasValue: false, hidden: true },
{ name: 'no-notify', description: 'disables notification when dyno is up (alternatively use HEROKU_NOTIFICATIONS=0)', hasValue: false }
],
run: cli.command(run)
}