I'm trying to compress a directory with Archiver. I want to exclude certain directories or files such as node_modules recursively.
For example, if I have a directory structure like this:
folder-to-compress
| node_modules
| sub-folder
| ignored-file-name
| included-file-name
| ignored-file-name
Below script only excludes from root level. So ignored-file-name
in root will not be included in zip but sub-folder/ignored-file-name
will be included. I'm wondering if there's a way to exclude recursively?
const fs = require('fs');
const archiver = require('archiver');
const output = fs.createWriteStream(__dirname);
const archive = archiver('zip', { zlib: { level: 9 } });
archive.pipe(output);
archive.glob('*/**', {
cwd: __dirname,
ignore: ['mode_modules', 'ignored-file-name', '*.zip']
});
archive.finalize();