mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 23:25:26 +00:00
Added more utils functions
This commit is contained in:
17
src/utils.ts
17
src/utils.ts
@@ -1,6 +1,6 @@
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { EOL } from "os";
|
import { EOL } from "os";
|
||||||
import { PartitionedBundle } from "./schema";
|
import { PartitionedBundle, BundleUnit } from "./schema";
|
||||||
import { sep } from "path";
|
import { sep } from "path";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,3 +105,18 @@ export function splitBufferBundle(origin: Object): [PartitionedBundle["l10nBundl
|
|||||||
}
|
}
|
||||||
}, [{},{}]);
|
}, [{},{}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StringSearchMode = "includes" | "startsWith" | "endsWith";
|
||||||
|
|
||||||
|
export function getAllFilesWithName(name: string, source: string[], mode: StringSearchMode = "includes", forceLowerCase: boolean = false): string[] {
|
||||||
|
return source.filter(file => (forceLowerCase && file.toLowerCase() || file)[mode](name));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hasFilesWithName(name: string, source: string[], mode: StringSearchMode = "includes", forceLowerCase: boolean = false): boolean {
|
||||||
|
return source.some(file => (forceLowerCase && file.toLowerCase() || file)[mode](name));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deletePersonalization(source: BundleUnit, logosNames: string[] = []): void {
|
||||||
|
[...logosNames, "personalization.json"]
|
||||||
|
.forEach(file => delete source[file]);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user