diff --git a/src/modules/Html/ProgressBar.ts b/src/modules/Html/ProgressBar.ts
index 1d8a6b3..fd329ff 100644
--- a/src/modules/Html/ProgressBar.ts
+++ b/src/modules/Html/ProgressBar.ts
@@ -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) {
@@ -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) {
@@ -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);
}
}