You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say I want to compress a directory. In the example, I am to do it as so:
// require modules
const fs = require('fs');
const archiver = require('archiver');
// create a file to stream archive data to.
const output = fs.createWriteStream(__dirname + '/example.zip');
const archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
});
// pipe archive data to the file
archive.pipe(output);
// append files from a sub-directory and naming it `new-subdir` within the archive
archive.directory('subdir/', 'new-subdir');
archive.finalize();
This is quite verbose, just to compress a directory. Could there be a helper function employed to make this one function call? It can detect whether the thing its compressing is a file or a directory, and what the compression algorithm should be based on the filetype of the output, and for the callback functions it could just have default print messages. For the other parameters, like the compression level, it could also have default params.
For example, instead of the code above, it could look something like:
const fs = require('fs');
const archiver = require('archiver');
archiver.compress('subdir/', 'example.zip') // .zip means zip compression.
Thoughts? Is this an issue people would be interested in me submitting a PR for?
The text was updated successfully, but these errors were encountered:
Say I want to compress a directory. In the example, I am to do it as so:
This is quite verbose, just to compress a directory. Could there be a helper function employed to make this one function call? It can detect whether the thing its compressing is a file or a directory, and what the compression algorithm should be based on the filetype of the output, and for the callback functions it could just have default print messages. For the other parameters, like the compression level, it could also have default params.
For example, instead of the code above, it could look something like:
Thoughts? Is this an issue people would be interested in me submitting a PR for?
The text was updated successfully, but these errors were encountered: