build: git context query format support

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2025-10-14 12:19:16 +02:00
parent 09c0f6a78e
commit 3bb4ae38ea
7 changed files with 135 additions and 69 deletions

View File

@@ -157,7 +157,10 @@ export class Util {
}
// https://github.com/golang/go/blob/f6b93a4c358b28b350dd8fe1780c1f78e520c09c/src/strconv/atob.go#L7-L18
public static parseBool(str: string): boolean {
public static parseBool(str: string | undefined): boolean {
if (str === undefined) {
return false;
}
switch (str) {
case '1':
case 't':
@@ -178,6 +181,14 @@ export class Util {
}
}
public static parseBoolOrDefault(str: string | undefined, defaultValue = false): boolean {
try {
return this.parseBool(str);
} catch {
return defaultValue;
}
}
public static formatFileSize(bytes: number): string {
if (bytes === 0) return '0 Bytes';
const k = 1024;