stdio pipe option returns an empty string
Stdio pipe option doesn't return the output. Using the inherit option reveals that the command executes successfully and logged in to the stdout.
Actual
import {execa} from 'execa';
const commandResult = await execa('npm', ['info', '@storybook/cli', 'version', '--json']);
console.log(commandResult);
❯ node testexec.js
{
command: 'npm info @storybook/cli version --json',
escapedCommand: 'npm info "@storybook/cli" version --json',
exitCode: 0,
stdout: '',
stderr: '',
all: undefined,
failed: false,
timedOut: false,
isCanceled: false,
killed: false
}
The stdout value shouldn't be an empty string.
Expected
import {execa} from 'execa';
const commandResult = await execa('npm', ['info', '@storybook/cli', 'version', '--json'], {stdio:'inherit'});
console.log(commandResult);
❯ node testexec.js
"8.0.9"
{
command: 'npm info @storybook/cli version --json',
escapedCommand: 'npm info "@storybook/cli" version --json',
exitCode: 0,
stdout: undefined,
stderr: undefined,
all: undefined,
failed: false,
timedOut: false,
isCanceled: false,
killed: false
}
Context
Origin issue: https://github.com/storybookjs/storybook/issues/26553#issuecomment-2082651356
Hi @pavitra-infocusp,
Thanks for reaching out.
When I run your first example on Ubuntu 23.10, Node 22.0.0, npm 10.6.0, Execa 8.0.1, I get the following result instead:
{
command: 'npm info @storybook/cli version --json',
escapedCommand: 'npm info "@storybook/cli" version --json',
exitCode: 0,
stdout: '"8.0.9"',
stderr: '',
all: undefined,
failed: false,
timedOut: false,
isCanceled: false,
killed: false
}
What is your OS, Node.js version, npm version and Execa version?
@pavitra-infocusp Did you end up solving this problem? If so, should we close this issue?
Yes, it did! Thanks for you help!