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

Fix updating multiline BottomBar #577

Merged

Conversation

dawidpawlowski
Copy link
Contributor

When I try to update my BottomBar by using updateBottomBar method and new text has more lines than previous text, content in console is overwritten. I make small fix to resolve this problem.

Code snippet to reproduce the problem:

var BottomBar = require('../lib/ui/bottom-bar');

var ui = new BottomBar();

function startInterval() {
  var i = 0;

  var inter = setInterval(function () {
    i++;

    var table = 'line - 1\nline - 2\nline - 3\nline - 4\nline - 5\nProgress - ' + i + '%';

    ui.updateBottomBar(table);

    if (i % 20 === 0) {
      ui.writeLog('work...');
    }

    if (i === 100) {
      clearInterval(inter);

      ui.updateBottomBar('Installation done!\n');

      process.exit();
    }
  }, 50);
}

startInterval();

Result before fix:
before_fix

Result after fix:
after_fix

Copy link
Owner

@SBoudrias SBoudrias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever fix, thanks!

I'll release a patch version later today.

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

Successfully merging this pull request may close these issues.

None yet

3 participants