* @param {object} details * @returns {Promise }
({files, dest, cwd, date, mode})
| 14 | * @returns {Promise<void>} |
| 15 | */ |
| 16 | function archiveFiles({files, dest, cwd, date, mode}) { |
| 17 | return new Promise((resolve) => { |
| 18 | const archive = new yazl.ZipFile(); |
| 19 | // Rproducible builds: sort filenames so files appear in the same order in zip |
| 20 | files.sort(); |
| 21 | files.forEach((file) => archive.addFile( |
| 22 | file, |
| 23 | file.startsWith(`${cwd}/`) ? file.substring(cwd.length + 1) : file, |
| 24 | {mtime: date, mode} |
| 25 | )); |
| 26 | /** @type {any} */ |
| 27 | const writeStream = fs.createWriteStream(dest); |
| 28 | archive.outputStream.pipe(writeStream).on('close', resolve); |
| 29 | archive.end(); |
| 30 | }); |
| 31 | } |
| 32 | |
| 33 | async function archiveDirectory({dir, dest, date, mode}) { |
| 34 | const files = await getPaths(`${dir}/**/*.*`); |