mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 17:25:21 +00:00
Added Bundle.prototype.isFrozen getter and used it to close pass if it is not yet frozen
This commit is contained in:
@@ -61,7 +61,7 @@ export default class Bundle {
|
||||
*/
|
||||
|
||||
protected freeze() {
|
||||
if (this[bundleStateSymbol] === BundleState.CLOSED) {
|
||||
if (this.isFrozen) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,15 @@ export default class Bundle {
|
||||
this[archiveSymbol].end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if this bundle still allows files to be added
|
||||
* @returns
|
||||
*/
|
||||
|
||||
public get isFrozen() {
|
||||
return this[bundleStateSymbol] === BundleState.CLOSED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows files to be added to the bundle.
|
||||
* If the bundle is closed, it will throw an error.
|
||||
@@ -78,7 +87,7 @@ export default class Bundle {
|
||||
*/
|
||||
|
||||
public addBuffer(fileName: string, buffer: Buffer) {
|
||||
if (this[bundleStateSymbol] === BundleState.CLOSED) {
|
||||
if (this.isFrozen) {
|
||||
throw new Error("Cannot add file. Bundle is closed.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user