mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +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 {
|
public getAsBuffer(): Buffer {
|
||||||
this[freezeSymbol]();
|
this[freezeSymbol]();
|
||||||
return zip.toBuffer(
|
return zip.toBuffer(createZipFilesMap(this[filesSymbol]));
|
||||||
Object.entries(this[filesSymbol]).map(([path, data]) => ({
|
|
||||||
path,
|
|
||||||
data,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +125,10 @@ export default class Bundle {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public getAsStream(): Stream {
|
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] });
|
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