mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
Added bundle to messages
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { Stream } from "stream";
|
import { Stream } from "stream";
|
||||||
|
import * as Messages from "../lib/messages";
|
||||||
import { default as Bundle, filesSymbol } from "../lib/Bundle";
|
import { default as Bundle, filesSymbol } from "../lib/Bundle";
|
||||||
|
|
||||||
describe("Bundle", () => {
|
describe("Bundle", () => {
|
||||||
@@ -59,7 +60,7 @@ describe("Bundle", () => {
|
|||||||
|
|
||||||
expect(() =>
|
expect(() =>
|
||||||
bundle.addBuffer("icon.png", Buffer.alloc(0)),
|
bundle.addBuffer("icon.png", Buffer.alloc(0)),
|
||||||
).toThrowError(Error, "Cannot add file. Bundle is closed.");
|
).toThrowError(Error, Messages.BUNDLE.CLOSED);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Stream } from "stream";
|
import { Stream } from "stream";
|
||||||
|
import * as Messages from "./messages";
|
||||||
import { ZipFile } from "yazl";
|
import { ZipFile } from "yazl";
|
||||||
|
|
||||||
export const filesSymbol = Symbol("bundleFiles");
|
export const filesSymbol = Symbol("bundleFiles");
|
||||||
@@ -87,7 +88,7 @@ export default class Bundle {
|
|||||||
|
|
||||||
public addBuffer(fileName: string, buffer: Buffer) {
|
public addBuffer(fileName: string, buffer: Buffer) {
|
||||||
if (this.isFrozen) {
|
if (this.isFrozen) {
|
||||||
throw new Error("Cannot add file. Bundle is closed.");
|
throw new Error(Messages.BUNDLE.CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
this[filesSymbol][fileName] = buffer;
|
this[filesSymbol][fileName] = buffer;
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ export const MODELS = {
|
|||||||
FILE_NO_OPEN: "Cannot open model file. %s",
|
FILE_NO_OPEN: "Cannot open model file. %s",
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const BUNDLE = {
|
||||||
|
CLOSED: "Cannot add file. Bundle is closed.",
|
||||||
|
} as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a message with replaced values
|
* Creates a message with replaced values
|
||||||
* @param messageName
|
* @param messageName
|
||||||
|
|||||||
Reference in New Issue
Block a user