Repository navigation
not zipping hidden files #4
Copy link
Copy link
Open
Description
Activity
@talfstad I know this is an old one, but in case anyone else has any issue with this, you can install
archiver(tested witharchiver@2.1.1) directly and use following snippet (also wrapped in promise so you can deal with it as such):/** * Wrap "archiver" package to create ZIP of the `sourceDir` and write it to `destinationFile` * * @param sourceDir * @param destinationFile * @returns {Promise<void>} */ async createArchive(sourceDir, destinationFile) { return new Promise((resolve, reject) => { // create a file to stream archive data to. const output = fs.createWriteStream(destinationFile); const archive = archiver("zip", { zlib: { level: 9 } // Sets the compression level. }); // listen for all archive data to be written // 'close' event is fired only when a file descriptor is involved output.on("close", function () { resolve("Archiving done"); }); // This event is fired when the data source is drained no matter what was the data source. // It is not part of this library but rather from the NodeJS Stream API. // @see: https://nodejs.org/api/stream.html#stream_event_end output.on("end", function () { logger.info(`Data has been drained to archive for ${sourceDir}`); }); // As per archvier docs - good practice to catch warnings (ie stat failures and other non-blocking errors) archive.on("warning", function (err) { if (err.code === "ENOENT") { // logger.warn(err); } else { // throw error reject(err); } }); // As per archvier docs - good practice to catch this error explicitly archive.on("error", function (err) { throw err; }); // Pipe archive data to the file archive.pipe(output); // Archive `sourceDir` to "node" dir in archive archive.directory(sourceDir, "node"); archive.finalize(); }); }Reacted by Ľuboš Michal and Thibault Brocheton
Metadata
Metadata
Assignees
Labels
No labels
using mac osx 10.11.5, node version 4.4.5, I used this tool to zip my built folder. It does not copy hidden files (that start with a '.') into the zip archive.
Is there an option I missed that I should have been passing? I did not find anything in the documentation.