From d2054c354b7986f5ad3edae1fdfcf23ff3195540 Mon Sep 17 00:00:00 2001 From: Inrixia Date: Fri, 5 Apr 2024 17:44:43 +1300 Subject: [PATCH] Better fix for MultiProgressBars taking over before it should --- src/lib/logging/ProgressBars.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/logging/ProgressBars.ts b/src/lib/logging/ProgressBars.ts index f1acc43..a75f495 100644 --- a/src/lib/logging/ProgressBars.ts +++ b/src/lib/logging/ProgressBars.ts @@ -2,13 +2,9 @@ import { MultiProgressBars } from "multi-progress-bars"; import { ProgressLogger, type IProgressLogger } from "./ProgressLogger.js"; import type { Progress } from "got"; import chalk from "chalk-template"; -import { args } from "../helpers/index.js"; export class ProgressBars extends ProgressLogger implements IProgressLogger { - // Ensure that MultiProgressBars is never instantiated if headless - private static readonly _Bars: MultiProgressBars = args.headless - ? (null) - : new MultiProgressBars({ initMessage: "", anchor: "bottom" }); + private static _Bars: MultiProgressBars; public static TotalBytes = 0; public static DownloadedBytes = 0; @@ -22,6 +18,8 @@ export class ProgressBars extends ProgressLogger implements IProgressLogger { readonly title: string; constructor(title: string) { super(); + if (ProgressBars._Bars === undefined) ProgressBars._Bars = new MultiProgressBars({ initMessage: "", anchor: "bottom" }); + this.title = title.trim().slice(0, 32).trim(); let i = 1; while (ProgressBars._Bars.getIndex(this.title) !== undefined) this.title = `${title.trim().slice(0, 32).trim()} [${++i}]`;