actions / actions/toolkit

`[command]…` output is prepended to exec `outStream`

Open
#649 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
I want to redirect a commands output to a file, but I still want the command that I execute to be logged.
Currently the [command]… log is streamed into the outStream, and not to stdout as I would expect.

To Reproduce
Steps to reproduce the behavior:

await exec.exec("echo", ["foobar"], { outStream: fs.createWriteStream("foobar.txt") });

Expected behavior
I want the foobar.txt file to only have foobar in it.
Instead, it will have the [command]echo foobar command output prepended.

Additional context

Not quite sure if this is intentional?

https://github.com/actions/toolkit/blob/2bf7365352507ee52b4017790934cf9cefabc5f4/packages/exec/src/toolrunner.ts#L424-L428

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/exec/src/toolrunner.ts around lines 424-428 and trace how command logging is written when outStream is supplied. Reproduce the issue with the echo example and verify that the output file contains only foobar while the command log remains on stdout.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.