SamVerschueren/listr

Console.log in Observable

Opened this issue · 1 comments

Thank you for maintaining this lib.

This code does not persists console.log ouput:

const Listr = require("listr");
const Observable = require("rxjs").Observable;

const tasks = new Listr([
  {
    title: "task",
    task: async () => {
      return new Observable(observer => {
        console.log("task - INIT");
        observer.next("Foo");

        setTimeout(() => {
          console.log("task - TIMEOUT 2000");
          observer.next("Bar");
        }, 2000);

        setTimeout(() => {
          console.log("task - TIMEOUT 4000");
          observer.complete();
        }, 4000);
      });
    }
  }
]);
tasks.run();

It displays:

✗ node test.js
task - INIT
 ⠏ task
 ⠇ task
 ✔ task

task - TIMEOUT 2000 and task - TIMEOUT 4000 just flash then break line.

Is it the normal behavior? Is there a way to avoid this?

My goal is to persists some error on console (warnings, errors and information that does not need to stop the process but are important).

Logging a line-break \n seems to help it persist