-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
37 lines (28 loc) · 820 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
var through = require('through2')
var PluginError = require('plugin-error')
var cloneStream = function() {
return through.obj(function(file, enc, cb) {
cb(null, file.clone());
});
};
var cloneSink = function() {
var tapStream = through.obj();
var stream = through.obj(function(file, enc, cb) {
if (file.isStream()) {
this.emit('error', new PluginError('gulp-clone', 'Streaming not supported'));
return cb();
}
if (file.isNull()) {
return cb(null, file); // Do nothing if no contents
}
tapStream.write(file.clone());
cb(null, file);
});
stream.tap = function() {
return tapStream;
};
return stream;
};
module.exports = cloneStream;
module.exports.sink = cloneSink;