mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 17:25:21 +00:00
Removed PKPass.pack to be async and moved an error to messages
This commit is contained in:
@@ -105,16 +105,12 @@ export default class PKPass extends Bundle {
|
||||
* @param passes
|
||||
*/
|
||||
|
||||
static async pack(...passes: PKPass[]): Promise<Bundle> {
|
||||
static pack(...passes: PKPass[]): Bundle {
|
||||
if (!passes.every((pass) => pass instanceof PKPass)) {
|
||||
throw new Error(
|
||||
"Cannot pack passes. Only PKPass instances allowed",
|
||||
);
|
||||
throw new Error(Messages.PACK.INVALID);
|
||||
}
|
||||
|
||||
const buffers = await Promise.all(
|
||||
passes.map((pass) => pass.getAsBuffer()),
|
||||
);
|
||||
const buffers = passes.map((pass) => pass.getAsBuffer());
|
||||
|
||||
const [bundle, freezeBundle] = Bundle.freezable(
|
||||
"application/vnd.apple.pkpasses",
|
||||
|
||||
@@ -78,6 +78,10 @@ export const BUNDLE = {
|
||||
CLOSED: "Cannot add file. Bundle is closed.",
|
||||
} as const;
|
||||
|
||||
export const PACK = {
|
||||
INVALID: "Cannot pack passes. Only PKPass instances allowed",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Creates a message with replaced values
|
||||
* @param messageName
|
||||
|
||||
Reference in New Issue
Block a user