index.js
function zipDirectory(directories, dest, callback) {
        var archive = archiver.create('zip', {gzip: false});

        // Where to write the file
        var destStream = fs.createWriteStream(dest);

        archive.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Archiving failed', err));
        });

        archive.on('entry', function(file) {
            // do nothing
        });

        destStream.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'WriteStream failed', err));
        });

        destStream.on('close', function() {
            var size = archive.pointer();
            gutil.log(PLUGIN_NAME, gutil.colors.green('Created ' + dest + ' (' + size + ' bytes)'));
            callback();
        });

        archive.pipe(destStream);

        directories.forEach(function(directory) {
            if (fs.lstatSync(directory.src).isDirectory()) {
              archive.directory(directory.src, directory.dest);
            } else {
              this.emit('error', new gutil.PluginError(PLUGIN_NAME, directory.src + ' is not a valid directory'));
              return;
            }
        });

        archive.finalize();
    }
function zipDirectory(directories, dest, callback) {
        var archive = archiver.create('zip', {gzip: false});

        // Where to write the file
        var destStream = fs.createWriteStream(dest);

        archive.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Archiving failed', err));
        });

        archive.on('entry', function(file) {
            // do nothing
        });

        destStream.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'WriteStream failed', err));
        });

        destStream.on('close', function() {
            var size = archive.pointer();
            gutil.log(PLUGIN_NAME, gutil.colors.green('Created ' + dest + ' (' + size + ' bytes)'));
            callback();
        });

        archive.pipe(destStream);

        directories.forEach(function(directory) {
            if (fs.lstatSync(directory.src).isDirectory()) {
              archive.directory(directory.src, directory.dest);
            } else {
              this.emit('error', new gutil.PluginError(PLUGIN_NAME, directory.src + ' is not a valid directory'));
              return;
            }
        });

        archive.finalize();
    }
function zipDirectory ( directories , dest , callback ) { var archive = archiver . create ( 'zip' , { gzip : false } ) ; // Where to write the file var destStream = fs . createWriteStream ( dest ) ; archive . on ( 'error' , function ( err ) { this . emit ( 'error' , new gutil . PluginError ( PLUGIN_NAME , 'Archiving failed' , err ) ) ; } ) ; archive . on ( 'entry' , function ( file ) { // do nothing } ) ; destStream . on ( 'error' , function ( err ) { this . emit ( 'error' , new gutil . PluginError ( PLUGIN_NAME , 'WriteStream failed' , err ) ) ; } ) ; destStream . on ( 'close' , function ( ) { var size = archive . pointer ( ) ; gutil . log ( PLUGIN_NAME , gutil . colors . green ( 'Created ' + dest + ' (' + size + ' bytes)' ) ) ; callback ( ) ; } ) ; archive . pipe ( destStream ) ; directories . forEach ( function ( directory ) { if ( fs . lstatSync ( directory . src ) . isDirectory ( ) ) { archive . directory ( directory . src , directory . dest ) ; } else { this . emit ( 'error' , new gutil . PluginError ( PLUGIN_NAME , directory . src + ' is not a valid directory' ) ) ; return ; } } ) ; archive . finalize ( ) ; }
Zips a set of directories and its contents using node-archiver.
@param directories
@param dest
@param zipCallback
Zips a set of directories and its contents using node - archiver .