()
| 169 | } |
| 170 | |
| 171 | stop(){ |
| 172 | |
| 173 | // stop timer |
| 174 | clearTimeout(this.timer); |
| 175 | this.timer = null; |
| 176 | |
| 177 | // remove sigint listener |
| 178 | if (this.sigintCallback){ |
| 179 | process.removeListener('SIGINT', this.sigintCallback); |
| 180 | process.removeListener('SIGTERM', this.sigintCallback); |
| 181 | this.sigintCallback = null; |
| 182 | } |
| 183 | |
| 184 | // set flag |
| 185 | this.isActive = false; |
| 186 | |
| 187 | // cursor hidden ? |
| 188 | if (this.options.hideCursor === true){ |
| 189 | this.terminal.cursor(true); |
| 190 | } |
| 191 | |
| 192 | // re-enable line wrpaping ? |
| 193 | if (this.options.linewrap === false){ |
| 194 | this.terminal.lineWrapping(true); |
| 195 | } |
| 196 | |
| 197 | // reset cursor |
| 198 | this.terminal.cursorRelativeReset(); |
| 199 | |
| 200 | // trigger event |
| 201 | this.emit('stop-pre-clear'); |
| 202 | |
| 203 | // clear line on complete ? |
| 204 | if (this.options.clearOnComplete){ |
| 205 | // clear all bars |
| 206 | this.terminal.clearBottom(); |
| 207 | |
| 208 | // or show final progress ? |
| 209 | }else{ |
| 210 | // update each bar |
| 211 | for (let i=0; i< this.bars.length; i++){ |
| 212 | // add new line ? |
| 213 | if (i > 0){ |
| 214 | this.terminal.newline(); |
| 215 | } |
| 216 | |
| 217 | // trigger final rendering |
| 218 | this.bars[i].render(); |
| 219 | |
| 220 | // stop |
| 221 | this.bars[i].stop(); |
| 222 | } |
| 223 | |
| 224 | // new line on complete |
| 225 | this.terminal.newline(); |
| 226 | } |
| 227 | |
| 228 | // trigger event |
no test coverage detected