dbushell / grunt-svg2png

Grunt plugin to rasterize SVG to PNG images using PhantomJS
MIT License
76 stars 37 forks source link

Should use a carraige return on the progress bar instead of a new line? #44

Open johnbburg opened 6 years ago

johnbburg commented 6 years ago

Currently the progress bar writes a new line for each incremental step of progress. It seems like the progress bar should be outputting a carraige return to overwrite the line instead. So:

Rasterizing SVG to PNG (30 files)...
0% [                                ] 0.00% (0.0s) 
0% [                                ] 3.33% (0.3s) 
0% [ ==                             ] 6.67% (0.4s) 
0% [ ===                            ] 10.00% (0.4s) 
0% [ ===                            ] 13.33% (0.5s) 
0% [ =====                          ] 16.67% (0.5s) 
0% [ ======                         ] 20.00% (0.5s) 
0% [ ======                         ] 23.33% (0.6s) 
0% [ ========                       ] 26.67% (0.6s) 
0% [ =========                      ] 30.00% (0.7s) 
0% [ =========                      ] 33.33% (0.7s) 
0% [ ===========                    ] 36.67% (0.7s) 
0% [ ============                   ] 40.00% (0.8s) 
0% [ ============                   ] 43.33% (0.8s) 
0% [ ==============                 ] 46.67% (0.8s) 
0% [ ===============                ] 50.00% (0.9s) 
0% [ ===============                ] 53.33% (0.9s) 
0% [ =================              ] 56.67% (1.0s) 
0% [ ==================             ] 60.00% (1.0s) 
0% [ ==================             ] 63.33% (1.0s) 
0% [ ====================           ] 66.67% (1.1s) 
0% [ =====================          ] 70.00% (1.1s) 
0% [ =====================          ] 73.33% (1.1s) 
0% [ =======================        ] 76.67% (1.2s) 
0% [ ========================       ] 80.00% (1.2s) 
0% [ ========================       ] 83.33% (1.3s) 
0% [ ==========================     ] 86.67% (1.3s) 
0% [ ===========================    ] 90.00% (1.3s) 
0% [ ===========================    ] 93.33% (1.4s) 
0% [ =============================  ] 96.67% (1.4s) 
0% [ ============================== ] 100.00% (1.4s) 
0% [ ============================== ] 100.00% (1.5s) 

>> Rasterization complete.

Vs.

Rasterizing SVG to PNG (30 files)...
0% [ ============================== ] 100.00% (1.1s) 
>> Rasterization complete.

(With an effect of a bar filling up over time).

This can be easily done by changing to a carraige return /r instead of a new line here:

process.stdout.write(str + (hasTerminal ? '' : "\n"));
johnbburg commented 6 years ago

This may be duplicate to #7