Zips up directories into buffers or saves zipped files to disk
Zips up a directory and saves the zip to disk or returns as a buffer.
$ npm install zip-dir
var zipdir = require'zip-dir';zipdir'/path/to/be/zipped'// `buffer` is the buffer of the zipped file;zipdir'/path/to/be/zipped' saveTo: '~/myzip.zip'// `buffer` is the buffer of the zipped file// And the buffer was saved to `~/myzip.zip`;// Use a filter option to prevent zipping other zip files!// Keep in mind you have to allow a directory to descend into!zipdir'/path/to/be/zipped' filter: path stat => !/\.zip$/testpath;// Use an `each` option to call a function everytime a file is added, and receives the pathzipdir'/path/to/be/zipped' each: path => console.logp "added!";
var zipdir = require('zip-dir');
dirPath recursively preserving directory structure and returns
the compressed buffer into
callback on success. If
options defined with a
saveTo path, then the callback will be delayed until the buffer has also
been saved to disk.
saveToA path to save the buffer to.
filterA function that is called for all items to determine whether or not they should be added to the zip buffer. Function is called with the
statsobject (fs.Stats). Return true to add the item; false otherwise. To include files within directories, directories must also pass this filter.
eachA function that is called everytime a file or directory is added to the zip.
- Add an option to not add empty directories if there are no valid children inside