clessg / progress-bar-webpack-plugin

A progress bar plugin for Webpack.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion : avoid logs collisions

etienne-dldc opened this issue · comments

Hi,

This is an enhancement proposition.

Here is the problem I had with your script : if something is logged while the progress bar is running, the log is append at the end of the progress bar and the progress bar continue on a new line.

You can avoid this with the following code :

process.stdout.write('\n') // Add a new line
process.stdout.clearLine() // clear the line because the previous progress bar is on this line
console.log('Progress █████████░░░░░░░░░░░░░░░')
process.stdout.write('\u001b[2A') // Move the cursor two line up (back to the empty line)
process.stdout.clearLine()
process.stdout.cursorTo(0)

You also need to check when the progress is full to restore the cursor on the last line and remove the empty line :

if (percentage === 1) {
  console.log('Progress ███████████████████████')
  console.log('DONE') // Or just clear this line
  process.stdout.clearLine()
  process.stdout.cursorTo(0)
}

Sorry that I do not have time to create a PR right now.

Let me know if you need more explanation about this.
Have a good day :)

+1

commented

@etienne-dldc could you commit a PR 😄 . Facing this problem too. The output looks ugly and strange.

The way I solve this was not that good because it was slowing down the build process because of the amount of console operation.
For now, in my project, I simply log progression steps one after the other and I'm also looking at npm/npmlog...

commented

In fact, I have also encounter a similar problem with using npm programmatically before.

The scene is that some of the npm log output are appended to my own log output.

发件人: Etienne Dldc [mailto:notifications@github.com]
发送时间: 2016年7月27日 20:55
收件人: clessg/progress-bar-webpack-plugin progress-bar-webpack-plugin@noreply.github.com
抄送: Scott saintscott119@gmail.com; Comment comment@noreply.github.com
主题: Re: [clessg/progress-bar-webpack-plugin] Suggestion : avoid logs collisions (#5)

The way I solve this was not that good because it was slowing down the build process because of the amount of console operation.
For now, in my project, I simply log progression steps one after the other and I'm also looking at npm/npmlog https://github.com/npm/npmlog ...


You are receiving this because you commented.
Reply to this email directly, view it on GitHub #5 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/AFAwulxpg6cPljk5VT9o30yDK1Ppqxb3ks5qZ1U7gaJpZM4H90dN . https://github.com/notifications/beacon/AFAwuhBecBVNZeJJLcPwwWz9cULBifklks5qZ1U7gaJpZM4H90dN.gif

I could be wrong, but I doubt that this can be fixed without destroying performance. In fact I doubt it can be fixed at all unless you control all possible output.

There are too many possible variables. Output could be written to either stdout or stderr. Multiple lines could be written in between bar updates. And so on.

If anybody knows of a way to sensibly fix this, please help out!