Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change heroku run -x implementation to use a Bash EXIT trap #2468

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/run-v5/lib/dyno.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Dyno extends Duplex {
}

_doStart(retries = 2) {
let command = this.opts['exit-code'] ? `${this.opts.command}; echo "\uFFFF heroku-command-exit-status: $?"` : this.opts.command
let command = this.opts['exit-code'] ? `trap 'echo -n "\uFFFF heroku-command-exit-status: $? \uFFFF"' EXIT; ${this.opts.command}` : this.opts.command
return this.heroku.post(this.opts.dyno ? `/apps/${this.opts.app}/dynos/${this.opts.dyno}` : `/apps/${this.opts.app}/dynos`, {
headers: {
Accept: this.opts.dyno ? 'application/vnd.heroku+json; version=3.run-inside' : 'application/vnd.heroku+json; version=3',
Expand Down Expand Up @@ -312,10 +312,10 @@ class Dyno extends Duplex {
// eslint-disable-next-line
if (!process.stdout.isTTY) data = data.replace(new RegExp('\r\n', 'g'), '\n')

let exitCode = data.match(/\uFFFF heroku-command-exit-status: (\d+)/m)
let exitCode = data.match(/\uFFFF heroku-command-exit-status: (\d+) \uFFFF/)
if (exitCode) {
debug('got exit code: %d', exitCode[1])
this.push(data.replace(/^\uFFFF heroku-command-exit-status: \d+$\n?/m, ''))
this.push(data.replace(/\uFFFF heroku-command-exit-status: \d+ \uFFFF/, ''))
let code = Number.parseInt(exitCode[1])
if (code === 0) this.resolve()
else {
Expand Down