MCPcopy Index your code
hub / github.com/darkreader/darkreader / archiveFiles

Function archiveFiles

tasks/zip.js:16–31  ·  view source on GitHub ↗

* @param {object} details * @returns {Promise }

({files, dest, cwd, date, mode})

Source from the content-addressed store, hash-verified

14 * @returns {Promise<void>}
15 */
16function 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
33async function archiveDirectory({dir, dest, date, mode}) {
34 const files = await getPaths(`${dir}/**/*.*`);

Callers 1

archiveDirectoryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected