dir-archiver

Compress a whole directory (including subdirectories) into a zip file, with options to exclude specific files, or directories.

Usage no npm install needed!

<script type="module">
  import dirArchiver from 'https://cdn.skypack.dev/dir-archiver';
</script>

README

npm license changelog

Dir Archiver

Compress a whole directory (including subdirectories) into a zip file, with options to exclude specific files, or directories.

Installation

$ npm install dir-archiver

Usage

API

// Require modules.
var DirArchiver = require('dir-archiver');

// Create an array with the files and directories to exclude.
const excludes = ['directory_name', 'file.extension'];

/**
 * Create a dir-archiver object. 
 * @param {string} directoryPath - The path of the folder to archive.
 * @param {string} zipPath - The path of the zip file to create.
 * @param {array} excludes - A list with the names of the files and folders to exclude.
*/
var archive = new DirArchiver('path/to/directory', 'path/to/desination/zipfile.zip', excludes);

// Create the zip file.
archive.createZip();

Command Line Interface

Usage: dir-archiver --src <path-to-directory> --dest <path-to-file>.zip --exclude folder-name file-name.extention

Options:
  --src      The path of the folder to archive.
  --dest     The path of the zip file to create.
  --exclude  Specify a list with the names of the files and folders to exclude