* Write zip contents to a file. * @param {JSZip} zip the zip object * @param {string} targetPath path to write the zip file to. * @return {Promise} a promise resolving to null.
(zip, targetPath)
| 31 | * @return {Promise} a promise resolving to null. |
| 32 | */ |
| 33 | function writeZip(zip, targetPath) { |
| 34 | const opts = { |
| 35 | platform: process.platform == 'win32' ? 'DOS' : 'UNIX', |
| 36 | compression: 'DEFLATE', |
| 37 | compressionOptions: { |
| 38 | level: 9, |
| 39 | }, |
| 40 | } |
| 41 | return new Promise((resolve) => { |
| 42 | zip |
| 43 | .generateNodeStream(opts) |
| 44 | .pipe(fse.createWriteStream(targetPath)) |
| 45 | .on('finish', resolve) |
| 46 | }).then(() => null) |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Add a new file to a zip file from a buffer. |
no outgoing calls
no test coverage detected
searching dependent graphs…