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

Execa streamed output support #37

Closed
MatissJanis opened this issue Jun 3, 2020 · 5 comments · Fixed by #38
Closed

Execa streamed output support #37

MatissJanis opened this issue Jun 3, 2020 · 5 comments · Fixed by #38
Labels

Comments

@MatissJanis
Copy link

Hey!

It would be very nice if listr2 would also have enquirer support just as the first version did. Currently it's possible to execute async commands and wait for them to complete, however streaming the output from them does not seem to be possible.

Example:

{
  title: "List files",
  task: (ctx) => {
    return execa.command(" ls -lah . && sleep 10 && ls -lah .");
  }
}

The command will execute successfully, however the output will not be streamed. I tried a bunch of different variations as well, but none were successful. The output is not being streamed to the console.

Help here would be much appreciated!

@cenk1cenk2 cenk1cenk2 added the bug Something isn't working label Jun 3, 2020
@cenk1cenk2
Copy link
Collaborator

I will have a look at this early tomorrow afternoon. I think it is time to expand the tests.

@cenk1cenk2
Copy link
Collaborator

You might redirect the stdout of execa using task.stdout. i am not sure if execa.command returns a promise or a stream. But i will anyway rewrite the stream to output conversion.

@MatissJanis
Copy link
Author

Piping to task.stdout works in terms of sending the output to listr, however then the problem is that any subsequent step is executed prior to the task finishing.

This might, however, be an execa issue. I ported some tasks to shelljs and it works.. not great, but much better. Provides the output and waits for the task to finish before proceeding.

{
  title: "List files",
  task: (ctx, task) => {
    const subprocess = execa(" ls -lah . && sleep 10 && ls -lah .");

    subprocess.stdout.pipe(task.stdout);
    return subprocess;
  }
}

cenk1cenk2 added a commit that referenced this issue Jun 3, 2020
@cenk1cenk2 cenk1cenk2 linked a pull request Jun 3, 2020 that will close this issue
cenk1cenk2 pushed a commit that referenced this issue Jun 3, 2020
# [2.1.0-beta.6](v2.1.0-beta.5...v2.1.0-beta.6) (2020-06-03)

### Bug Fixes

* **deps:** remove trivial deps ([de8dec0](de8dec0))
* **deps:** remove unnecassary types ([b37f416](b37f416))
* **deps:** updated deps to latest ([c4ad38f](c4ad38f))
* **stream:** fixed streams added example ([614d89f](614d89f)), closes [#37](#37)
@cenk1cenk2
Copy link
Collaborator

🎉 This issue has been resolved in version 2.1.0-beta.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

cenk1cenk2 pushed a commit that referenced this issue Jun 3, 2020
# [2.1.0](v2.0.4...v2.1.0) (2020-06-03)

### Bug Fixes

* **deps:** remove trivial deps ([de8dec0](de8dec0))
* **deps:** remove unnecassary types ([b37f416](b37f416))
* **deps:** updated deps to latest ([c4ad38f](c4ad38f))
* **figures:** made microsoft icons to use the fancy ones, even though it may fail in some cases ([f0e5817](f0e5817)), closes [#31](#31)
* **prompt:** enquirer to peer ([cae55e9](cae55e9))
* **prompt:** types ([110130a](110130a))
* **prompts:** fixed type for array prompts, added name as mandatory ([a08b1e4](a08b1e4))
* **stream:** fixed streams added example ([614d89f](614d89f)), closes [#37](#37)

### Features

* **prompt:** make prompt module optional, be more compatible to underlying enqurier ([64cecc1](64cecc1)), closes [#34](#34)
* **prompt:** use enquirer directly ([b34e9d0](b34e9d0)), closes [#34](#34)
* **renderer:** added hook and stdout support ([bd73c68](bd73c68)), closes [#31](#31)
@cenk1cenk2
Copy link
Collaborator

🎉 This issue has been resolved in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants