shellJS swallows Heroku CLI output and fails with undefined error
See original GitHub issueNode version 12.16.1
ShellJS version “^0.8.3”
Operating system: Ubuntu 18
Description of the bug: ShellJS fails without any stdout when running Heroku commands
Example ShellJS command to reproduce the error:
Install the Heroku CLI
I am evaluating the use of ShellJS in helping me move my deployment/CI pipeline to TS instead of a bunch of bash scripts.
Everything is currently working fine in bash land, but when I try running heroku commands in ShellJS it just errors out with no output of any kind.
For example
shell.set(`-v`)
const result = shell.exec(`heroku --help`);
console.log(result);
const child = shell.exec(`heroku login`, {async: true});
child.stdout.on('data', function(data) {
console.log(data);
});
Results in:
console.log tests/create_app.test.ts:25
[String: ''] {
stdout: '',
stderr: '',
code: 0,
cat: [Function: bound ],
exec: [Function: bound ],
grep: [Function: bound ],
head: [Function: bound ],
sed: [Function: bound ],
sort: [Function: bound ],
tail: [Function: bound ],
to: [Function: bound ],
toEnd: [Function: bound ],
uniq: [Function: bound ]
}
Some of the processes hang long enough that it makes me think something is happening, but without any way to debug it is hard to tell.
My current handler for exec looks like this,
static async execAsync(cmd, opts={}): Promise<string> {
return new Promise(function(resolve, reject) {
// Execute the command, reject if we exit non-zero (i.e. error)
const child = shell.exec(cmd, {shell: '/bin/bash', ...opts}, function(code, stdout) {
if (code != 0) return reject(new Error(stdout));
return resolve(stdout);
});
child.stdout.on('data', function(data) {
console.log(data);
});
});
}
If this is problem with the Heroku CLI I understand, but I find that hard to believe considering that all of these commands work perfectly fine elsewhere.
Linking to the Heroku CLI ticket for reference: https://github.com/heroku/cli/issues/1478
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Release Phase | Heroku Dev Center
Release command failure; Checking release status & logs; Canceling a release command; Review apps and the postdeploy script ...
Read more >The definitive Node.js handbook - Medium
The first value, test , is the output we told the console to print, then we get undefined which is the return value...
Read more >Node.js Handbook - lcg.ufrj
The first value, test , is the output we told the console to print, then we get undefined which is the return value...
Read more >Node.js Handbook - Amazon S3
How to print to the command line console using Node, from the basic ... Or a bug in the latest release of a...
Read more >Node.js Notes for Professionals
Section 13.2: process.argv command line arguments ... errors thrown in a promise that are not caught results in the error being swallowed, which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It’s unclear where this output is coming from. Might help to change your log line to something like:
You could also add
{ silent: true, async: true }to the exec call, or else you’ll get double-logging.@nfischer I’m closing this as the issue seems to be related to the shell executing the heroku commands and not your library, thanks for the help.