execa icon indicating copy to clipboard operation
execa copied to clipboard

stdio pipe option returns an empty string

Open pavitra-infocusp opened this issue 1 year ago • 2 comments

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

pavitra-infocusp avatar Apr 29 '24 13:04 pavitra-infocusp

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?

ehmicky avatar Apr 29 '24 16:04 ehmicky

@pavitra-infocusp Did you end up solving this problem? If so, should we close this issue?

ehmicky avatar May 18 '24 05:05 ehmicky

Yes, it did! Thanks for you help!

pavitra-infocusp avatar May 20 '24 07:05 pavitra-infocusp