Skip to content

Instantly share code, notes, and snippets.

@mushfiq

mushfiq/.gitignore

Last active Jul 7, 2020
Embed
What would you like to do?
node_modules/*
*.data
npm install archiver;
var archiver = require('archiver'),
archive = archiver('zip'),
fs = require('fs');
var output = fs.createWriteStream(__dirname + '/mocks.zip');
archive.pipe(output);
var getStream = function(fileName){
return fs.readFileSync(fileName);
}
//these are the files, want to put into zip archive
var fileNames = ['mock1.data', 'mock2.data', 'mock3.data'];
for(i=0; i<fileNames.length; i++){
var path = __dirname + '/'+fileNames[i];
archive.append(getStream(path), { name: fileNames[i]});
}
archive.finalize(function(err, bytes) {
if (err) {
throw err;
}
console.log(bytes + ' total bytes');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.