build: git context query format support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
13
src/util.ts
13
src/util.ts
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user