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

stdio pipe option returns an empty string #995

Closed
pavitra-infocusp opened this issue Apr 29, 2024 · 3 comments
Closed

stdio pipe option returns an empty string #995

pavitra-infocusp opened this issue Apr 29, 2024 · 3 comments

Comments

@pavitra-infocusp
Copy link

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: storybookjs/storybook#26553 (comment)

@pavitra-infocusp pavitra-infocusp changed the title stdio pipe option doesn't work stdio pipe option returns an empty string Apr 29, 2024
@ehmicky
Copy link
Collaborator

ehmicky commented Apr 29, 2024

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
Copy link
Collaborator

ehmicky commented May 18, 2024

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

@pavitra-infocusp
Copy link
Author

pavitra-infocusp commented May 20, 2024

Yes, it did! Thanks for you help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants