MCPcopy Create free account
hub / github.com/npkgz/cli-progress / render

Method render

lib/generic-bar.js:53–101  ·  view source on GitHub ↗
(forceRendering=false)

Source from the content-addressed store, hash-verified

51
52 // internal render function
53 render(forceRendering=false){
54
55 // formatter params
56 const params = {
57 progress: this.getProgress(),
58 eta: this.eta.getTime(),
59 startTime: this.startTime,
60 stopTime: this.stopTime,
61 total: this.total,
62 value: this.value,
63 maxWidth: this.terminal.getWidth()
64 };
65
66 // automatic eta update ? (long running processes)
67 if (this.options.etaAsynchronousUpdate){
68 this.updateETA();
69 }
70
71 // format string
72 const s = this.formatter(this.options, params, this.payload);
73
74 const forceRedraw = forceRendering || this.options.forceRedraw
75 // force redraw in notty-mode!
76 || (this.options.noTTYOutput && !this.terminal.isTTY());
77
78 // string changed ? only trigger redraw on change!
79 if (forceRedraw || this.lastDrawnString != s){
80 // trigger event
81 this.emit('redraw-pre');
82
83 // set cursor to start of line
84 this.terminal.cursorTo(0, null);
85
86 // write output
87 this.terminal.write(s);
88
89 // clear to the right from cursor
90 this.terminal.clearRight();
91
92 // store string
93 this.lastDrawnString = s;
94
95 // set last redraw time
96 this.lastRedraw = Date.now();
97
98 // trigger event
99 this.emit('redraw-post');
100 }
101 }
102
103 // start the progress bar
104 start(total, startValue, payload){

Callers

nothing calls this directly

Calls 8

getProgressMethod · 0.95
updateETAMethod · 0.95
getTimeMethod · 0.80
getWidthMethod · 0.80
isTTYMethod · 0.80
cursorToMethod · 0.80
writeMethod · 0.80
clearRightMethod · 0.80

Tested by

no test coverage detected