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

Unable to output message after task message #16

Open
vitormv opened this issue Apr 8, 2022 · 2 comments
Open

Unable to output message after task message #16

vitormv opened this issue Apr 8, 2022 · 2 comments

Comments

@vitormv
Copy link

vitormv commented Apr 8, 2022

Bug description

I want to output a message AFTER all the tasks have run, but it seems Tasuku somehow always hijacks the order of messages. I tried to use .then() and await the task itself, but no success...

How can I ensure my message is displayed AFTER the task messages?

Reproduction

import task from 'tasuku';

const delay = (ms) => {
    return new Promise(function(resolve) {
        setTimeout(resolve, ms);
    });
}

const response = await
  task( `My task`, () => (delay(100)))
  .then(() => {
    console.log('THEN command');
  });

console.log('should print after response, no?');

Output

Screenshot 2022-04-08 at 11 59 06

Environment

  • tasuku version: 1.0.2
  • Operating System: OSX Monterey 12.2.1
  • Node version: v14.18.2
  • Package manager (npm/yarn/pnpm) and version:
@mixn
Copy link

mixn commented Apr 12, 2023

@vitormv Did you manage to solve this somehow? I’m like 80% into migrating a big CLI from Listr to tasuku and am only now noticing that I’m having this issue. 😨 Really need to be able to give some final feedback once the last tasuku task has finished.

Thanks in advance.

@erictheswift
Copy link

I guess there's a workaround — you need to wrap console.logs and use taskApi.setOutput for display. Not sure if putting anything in console in unmanaged fashion is supported by ink (tasuku is running on)

As a workaround for logging you may use stderr (console.error) as output and redirect stderr via 2>/dev/ttysX where /dev/ttysX is just the example of tty command run in another terminal) but that's troublesome.

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

3 participants