Skip to content

Commit c0fedb5

Browse files
Merge pull request #26 from terrierscript/development
v1.1.0 - Gulp@4 Compatibility!
2 parents 53a84d6 + 583983f commit c0fedb5

File tree

5 files changed

+2485
-144
lines changed

5 files changed

+2485
-144
lines changed

file.zip

578 KB
Binary file not shown.

index.js

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,52 @@
1-
const through = require('through2').obj,
2-
unzip = require('unzipper'),
3-
Vinyl = require('vinyl');
1+
const Stream = require('stream')
2+
3+
const through = require('through2').obj
4+
5+
const unzip = require('unzipper')
6+
7+
const Vinyl = require('vinyl')
48

59
module.exports = (options = {}) => {
6-
7-
function transform(file, enc, callback){
10+
function transform (file, enc, callback) {
811
if (file.isNull()) {
9-
this.push(file);
10-
return callback();
12+
this.push(file)
13+
return callback()
1114
}
1215

13-
const opts = {};
14-
opts.filter = options.filter || (() => true);
15-
opts.keepEmpty = options.keepEmpty || false;
16+
let stream = new Stream.PassThrough()
1617

17-
file.pipe(unzip.Parse())
18+
if (file.isBuffer() && !file.pipe) {
19+
stream.end(file.contents)
20+
} else {
21+
stream = file
22+
}
23+
24+
const opts = {}
25+
opts.filter = options.filter || (() => true)
26+
opts.keepEmpty = options.keepEmpty || false
27+
28+
stream.pipe(unzip.Parse())
1829
.on('entry', entry => {
19-
const chunks = [];
20-
if(!opts.filter(entry)){
21-
entry.autodrain();
22-
return;
30+
const chunks = []
31+
if (!opts.filter(entry)) {
32+
entry.autodrain()
33+
return
2334
}
24-
35+
2536
entry.pipe(through((chunk, enc, cb) => {
26-
chunks.push(chunk);
27-
cb();
37+
chunks.push(chunk)
38+
cb()
2839
}, cb => {
29-
if(entry.type === 'File' && (chunks.length > 0 || opts.keepEmpty)){
40+
if (entry.type === 'File' && (chunks.length > 0 || opts.keepEmpty)) {
3041
this.push(new Vinyl({
31-
cwd : "./",
32-
path : entry.path,
42+
cwd: './',
43+
path: entry.path,
3344
contents: Buffer.concat(chunks)
34-
}));
45+
}))
3546
}
36-
cb();
37-
}));
38-
}).on('close', callback);
47+
cb()
48+
}))
49+
}).on('close', callback)
3950
}
40-
return through(transform);
41-
};
51+
return through(transform)
52+
}

0 commit comments

Comments
 (0)