Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/modules/Html/ProgressBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export class LoadingBar{
let _left = this.currentIndex - 1;
_left = _left < 0 ? 0 : _left;
let _right = this.bar_length - _left - 1;
process.stdout.write(`${this.message}${this.chunksDownloaded} :` + chalk.green(` ${this.empty.repeat(_left)}${this.fill}${this.empty.repeat(_right)}`));
process.stdout?.write(`${this.message}${this.chunksDownloaded} :` + chalk.green(` ${this.empty.repeat(_left)}${this.fill}${this.empty.repeat(_right)}`));
}
clear(){
//@ts-ignore
process.stdout.clearLine();
process.stdout?.clearLine();
//@ts-ignore
process.stdout.cursorTo(0);
process.stdout?.cursorTo(0);
}

start(speed?:number) {
Expand Down Expand Up @@ -83,7 +83,7 @@ export class ProgressBar {
constructor(total?:number) {
this.total = total || null;
this.current = 0;
this.bar_length = process.stdout.columns - 30;
this.bar_length = process.stdout.columns ? process.stdout.columns - 30 : 0;
// this.bar_length = 50;
}
next(progress) {
Expand All @@ -96,13 +96,13 @@ export class ProgressBar {

this.clearLine();
const _str = ` ${_p}% : ${chalk.green(this.bar_fill.repeat(_left-1)+_in_progress_code)}${ this.barr_empty.repeat(_right)}`;
process.stdout.write(_str);
process.stdout?.write(_str);
// console.log(_left, _right)
}
clearLine() {
//@ts-ignore
process.stdout.clearLine();
process.stdout?.clearLine();
//@ts-ignore
process.stdout.cursorTo(0);
process.stdout?.cursorTo(0);
}
}