Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple archive is very verbose #780

Open
sharoninator opened this issue Jul 30, 2024 · 0 comments
Open

Simple archive is very verbose #780

sharoninator opened this issue Jul 30, 2024 · 0 comments

Comments

@sharoninator
Copy link

sharoninator commented Jul 30, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant