提交 59c4f24c 编写于 作者: J Joao Moreno

gulp: beware of es.merge and empty arrays

fixes the internal builds
上级 fa614d82
......@@ -135,29 +135,33 @@ exports.optimizeTask = function(opts) {
var loaderConfig = opts.loaderConfig;
var bundledFileHeader = opts.header;
var out = opts.out;
return function() {
var bundles = es.through();
var bundlesStream = es.through();
bundle.bundle(entryPoints, loaderConfig, function(err, result) {
if (err) { return bundles.emit('error', JSON.stringify(err)); }
if (err) { return bundlesStream.emit('error', JSON.stringify(err)); }
toBundleStream(bundledFileHeader, result).pipe(bundles);
toBundleStream(bundledFileHeader, result).pipe(bundlesStream);
});
var otherSourcesStream = es.through();
(function() {
var otherSourcesStreamArr = [];
gulp.src(otherSources, { base: 'out-build' })
.pipe(es.through(function write(data) {
otherSourcesStreamArr.push(toConcatStream(bundledFileHeader, [data], data.relative));
}, function end() {
var otherSourcesStreamArr = [];
gulp.src(otherSources, { base: 'out-build' })
.pipe(es.through(function (data) {
otherSourcesStreamArr.push(toConcatStream(bundledFileHeader, [data], data.relative));
}, function () {
if (!otherSourcesStreamArr.length) {
setTimeout(function () { otherSourcesStream.emit('end'); }, 0);
} else {
es.merge(otherSourcesStreamArr).pipe(otherSourcesStream);
}))
})();
}
}));
var result = es.merge(
loader(bundledFileHeader),
bundles,
bundlesStream,
otherSourcesStream,
gulp.src(resources, { base: 'out-build' })
);
......
......@@ -2,7 +2,8 @@ declare module "event-stream" {
import { Stream } from 'stream';
import { ThroughStream } from 'through';
function merge(...stream: Stream[]): ThroughStream;
function merge(streams: Stream[]): ThroughStream;
function merge(...streams: Stream[]): ThroughStream;
function concat(...stream: Stream[]): ThroughStream;
function duplex(istream: Stream, ostream: Stream): ThroughStream;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册