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

Method stop

lib/single-bar.js:96–140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

94
95 // stop the bar
96 stop(){
97 // timer inactive ?
98 if (!this.timer) {
99 return;
100 }
101
102 // remove sigint listener
103 if (this.sigintCallback){
104 process.removeListener('SIGINT', this.sigintCallback);
105 process.removeListener('SIGTERM', this.sigintCallback);
106 this.sigintCallback = null;
107 }
108
109 // trigger final rendering
110 this.render();
111
112 // restore state
113 super.stop();
114
115 // stop timer
116 clearTimeout(this.timer);
117 this.timer = null;
118
119 // cursor hidden ?
120 if (this.options.hideCursor === true){
121 this.terminal.cursor(true);
122 }
123
124 // re-enable line wrapping ?
125 if (this.options.linewrap === false){
126 this.terminal.lineWrapping(true);
127 }
128
129 // restore cursor on complete (position + settings)
130 this.terminal.cursorRestore();
131
132 // clear line on complete ?
133 if (this.options.clearOnComplete){
134 this.terminal.cursorTo(0, null);
135 this.terminal.clearLine();
136 }else{
137 // new line on complete
138 this.terminal.newline();
139 }
140 }
141}

Callers

nothing calls this directly

Calls 7

renderMethod · 0.95
cursorMethod · 0.80
lineWrappingMethod · 0.80
cursorRestoreMethod · 0.80
cursorToMethod · 0.80
clearLineMethod · 0.80
newlineMethod · 0.80

Tested by

no test coverage detected