Skip to content

Commit

Permalink
added linter
Browse files Browse the repository at this point in the history
  • Loading branch information
UlisesGascon committed May 30, 2019
1 parent 43311cf commit 3b094cc
Show file tree
Hide file tree
Showing 4 changed files with 1,496 additions and 132 deletions.
67 changes: 34 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
const Stream = require('stream'),
through = require('through2').obj,
unzip = require('unzipper'),
Vinyl = require('vinyl');
const Stream = require('stream')

module.exports = (options = {}) => {

const through = require('through2').obj

const unzip = require('unzipper')

const Vinyl = require('vinyl')

function transform(file, enc, callback){
module.exports = (options = {}) => {
function transform (file, enc, callback) {
if (file.isNull()) {
this.push(file);
return callback();
this.push(file)
return callback()
}

let stream = new Stream.PassThrough();
let stream = new Stream.PassThrough()

if ( file.isBuffer() && !file.pipe ) {
stream.end( file.contents );
} else {
stream = file;
if (file.isBuffer() && !file.pipe) {
stream.end(file.contents)
} else {
stream = file
}

const opts = {};
opts.filter = options.filter || (() => true);
opts.keepEmpty = options.keepEmpty || false;
const opts = {}
opts.filter = options.filter || (() => true)
opts.keepEmpty = options.keepEmpty || false

stream.pipe(unzip.Parse())
.on('entry', entry => {
const chunks = [];
if(!opts.filter(entry)){
entry.autodrain();
return;
const chunks = []
if (!opts.filter(entry)) {
entry.autodrain()
return
}

entry.pipe(through((chunk, enc, cb) => {
chunks.push(chunk);
cb();
chunks.push(chunk)
cb()
}, cb => {
if(entry.type === 'File' && (chunks.length > 0 || opts.keepEmpty)){
if (entry.type === 'File' && (chunks.length > 0 || opts.keepEmpty)) {
this.push(new Vinyl({
cwd : "./",
path : entry.path,
cwd: './',
path: entry.path,
contents: Buffer.concat(chunks)
}));
}))
}
cb();
}));
}).on('close', callback);
cb()
}))
}).on('close', callback)
}
return through(transform);
};
return through(transform)
}

0 comments on commit 3b094cc

Please sign in to comment.