Easily zip paths
CoffeeScript Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
LICENSE
Makefile
README.md
index.js
package.json

README.md

zip-paths

Codeship Status for goansible/zip-paths

Node module to zip paths using file globbing.

This is basically a wrapper around node-archiver that uses node-glob to queue up files for compression.

The paths that match the globbing pattern are used in the resulting zip file.

Installation

npm install zip-paths

Usage

var zipPaths = require('zip-paths');
zip = new zipPaths('out.zip');

zip.add('js/*.js', function(err) {
  if (err) { /* handle error */ }
  zip.compress(function(err, bytes) {
    console.log("wrote %s bytes", bytes)
  });
});

Initialization

new zipPaths('path/to/zipfile.zip', [options])

The first parameter is the desired file path of the resulting archive.

options is pased to node-archiver. In the case of zip, they get passed directly to node's zlib. Default level is 9.

Options:

refer to zlib for zip options. Additional options include:

  • archiveType: Type of archive to create, zip or tar - default zip

zip.add(pattern, [options], callback(err){})

Add files to be zipped. Using globbing patters here (such as path/*.ext) is valid (see node-glob for more info).

You can optionally pass in an options opbject that will be passed directly to node-glob. Passing in cwd will adjust the paths in the resulting archive as well.

zip.getFiles()

Return an array of all files queued for archiving.

zip.compress(callback(err, bytes){})

Create the archive. Calls node-archive's finalize method directly and passes the callback along.