* Add a new file to a zip file from a buffer. * @param {JSZip} zip the zip object to add the file to. * @param {string} zipPath the target path in the zip. * @param {Promise} bufferPromise a promise providing a nodebuffer. * @return {Promise} a promise providing the JSZip object. * @param {obje
(zip, zipPath, bufferPromise, fileOpts)
| 55 | * @param {object} fileOpts an object with the opts to save for the file in the zip. |
| 56 | */ |
| 57 | async function zipFile(zip, zipPath, bufferPromise, fileOpts) { |
| 58 | const buffer = await bufferPromise |
| 59 | zip.file( |
| 60 | zipPath, |
| 61 | buffer, |
| 62 | Object.assign( |
| 63 | {}, |
| 64 | { |
| 65 | // necessary to get the same hash when zipping the same content |
| 66 | date: new Date(0), |
| 67 | }, |
| 68 | fileOpts, |
| 69 | ), |
| 70 | ) |
| 71 | return zip |
| 72 | } |
| 73 | |
| 74 | export { addTree, writeZip, zipFile } |
no outgoing calls
no test coverage detected
searching dependent graphs…