mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
Fixed Bundle methods calling javascript confusion: Bundle.getAsStream was calling this.getAsBuffer, but this was PKPass instance
This commit is contained in:
@@ -113,12 +113,7 @@ export default class Bundle {
|
||||
|
||||
public getAsBuffer(): Buffer {
|
||||
this[freezeSymbol]();
|
||||
return zip.toBuffer(
|
||||
Object.entries(this[filesSymbol]).map(([path, data]) => ({
|
||||
path,
|
||||
data,
|
||||
})),
|
||||
);
|
||||
return zip.toBuffer(createZipFilesMap(this[filesSymbol]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +125,10 @@ export default class Bundle {
|
||||
*/
|
||||
|
||||
public getAsStream(): Stream {
|
||||
return Readable.from(this.getAsBuffer());
|
||||
this[freezeSymbol]();
|
||||
return Readable.from(
|
||||
zip.toBuffer(createZipFilesMap(this[filesSymbol])),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,3 +146,17 @@ export default class Bundle {
|
||||
return Object.freeze({ ...this[filesSymbol] });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a files map for do-not-zip
|
||||
*
|
||||
* @param files
|
||||
* @returns
|
||||
*/
|
||||
|
||||
function createZipFilesMap(files: { [key: string]: Buffer }) {
|
||||
return Object.entries(files).map(([path, data]) => ({
|
||||
path,
|
||||
data,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user