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

[Bug]: ProcessOutput Releases w/o Line Breaks #670

Closed
3 tasks done
straub opened this issue Apr 11, 2023 · 8 comments
Closed
3 tasks done

[Bug]: ProcessOutput Releases w/o Line Breaks #670

straub opened this issue Apr 11, 2023 · 8 comments
Assignees
Labels
bug Something isn't working released

Comments

@straub
Copy link

straub commented Apr 11, 2023

Replication of the Problem

const { Listr } = require('listr2');

const tasks = new Listr({
  task: () => {
    console.log('one');
    console.log('two');
  },
})

tasks.run();
// Outputs "onetwo"

Problem

Hi there,

I'm trying to use Listr2@6 in my CLI, but when tasks have console output, line breaks are lost during release(). The output comes out all glued together in one line, which is difficult to read.

(Also, is there a way to opt out of output during release? I'd prefer to hide it entirely, but I couldn't see a related option in the docs / source.)

Let me know if you need further details!

Environment

MacOS Ventura 13.2.1
Node.js 16.20.0
iTerm2 3.4.19
listr2@6.0.3

Log Output

onetwo

Preflight

@straub straub added the bug Something isn't working label Apr 11, 2023
cenk1cenk2 added a commit that referenced this issue Apr 11, 2023
@cenk1cenk2
Copy link
Collaborator

cenk1cenk2 commented Apr 11, 2023

Thank you for reporting this @straub!

I shouldn't have refactored this part before releasing a major version but I am glad you caught it early on.

TBH, I am not fully myself today so I did not give it a fair share of testing but the release should be out soon with the given fix.

Even though disabling the process output part is not very convenient as a renderer option, it is now doable without passing your own implementation.

You can check out the related section https://listr2.kilic.dev/renderer/process-output.html, a bit after the pipeline finishes.

cenk1cenk2 pushed a commit that referenced this issue Apr 11, 2023
# [6.1.0](v6.0.4...v6.1.0) (2023-04-11)

### Bug Fixes

* add options to processoutput fix eol problem ([e6d6474](e6d6474)), closes [#670](#670)
* **process-output:** make everything optional ([148cb81](148cb81))

### Features

* add related documentation to process output and update with feature flag ([c1ede63](c1ede63))
cenk1cenk2 pushed a commit that referenced this issue Apr 11, 2023
# [6.1.0](v6.0.4...v6.1.0) (2023-04-11)

### Bug Fixes

* add options to processoutput fix eol problem ([e6d6474](e6d6474)), closes [#670](#670)
* **process-output:** make everything optional ([148cb81](148cb81))

### Features

* add related documentation to process output and update with feature flag ([c1ede63](c1ede63))
@cenk1cenk2
Copy link
Collaborator

🎉 This issue has been resolved in version 6.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@straub
Copy link
Author

straub commented Apr 11, 2023

Thank you for the quick response!

Unfortunately, using the new dump option, the streams that aren't dumped stay hijacked permanently. (And I must have a lot of console logging happening with empty messages or possibly just ANSI codes, because v6.1 without changing dump now outputs many blank lines between the original output for me.)

For now, I'm taking your recommendation and making a custom implementation of ProcessOutput that changes just the release() behavior:

// Hide all console output from tasks at completion.
class QuietProcessOutput extends ProcessOutput {
    release () {
        Object.values(this.stream)
        .forEach((stream) => stream.release());

        this.stream.stdout.write(ANSI_ESCAPE_CODES.CURSOR_SHOW);

        this.active = false;
    }
}

@cenk1cenk2
Copy link
Collaborator

Thank you for the feedback. I am honestly a bit sick today and not feeling my self but I will give this another go and fix this permanently so will reopen the issue to inform you back whenever it is done.

@straub
Copy link
Author

straub commented Apr 11, 2023

Please don't rush on my account. Feel better soon!

cenk1cenk2 pushed a commit that referenced this issue Apr 11, 2023
# [6.2.0](v6.1.0...v6.2.0) (2023-04-11)

### Bug Fixes

* update filtering reordering mechanism ([a72cc7b](a72cc7b)), closes [#670](#670)

### Features

* force publish since semantic-release is stuck ([fa0fae1](fa0fae1))
@cenk1cenk2
Copy link
Collaborator

🎉 This issue has been resolved in version 6.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@straub
Copy link
Author

straub commented Apr 11, 2023

6.2 resolved my issues! Streams are releasing with no extra blank lines :)

I'm using new ProcessOutput(null, null, { dump: [] }) rather than my custom subclass now. Thanks again!

@cenk1cenk2
Copy link
Collaborator

No problems at all. I am glad it was a quick fix for you and thank you again for reporting the issue.

Have a very nice day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants