I'm trying clone npm packages to a client-side location, so I have created multiple streams to accomplish this and merge them to return from gulp.task()
. However, it is my understanding that I will need to pause the streams in order for the task to receive the proper exit.
The following code runs without error, but if I comment the return
line. One of the packages is still copied, when I would expect none of the streams to reach their gulp.dest()
. Why aren't all the streams paused?
var gulp = require('gulp')
, eventStream = require('event-stream')
;
const projects = {
src: {
dependencies: {
codemirror: './src/lib/codemirror',
acorn: './src/lib/acorn'
}
}
};
gulp.task('init:client-packages', function () {
let streams = []
, ps = eventStream.pause();
// Load project client-side dependencies
for (let prj in projects) {
for (let pkg in projects[prj].dependencies) {
streams.push(
gulp.src('./node_modules/' + pkg + '/**')
.pipe(ps)
.pipe(gulp.dest(projects[prj].dependencies[pkg]))
);
}
}
// Merge source streams
return eventStream.merge(streams).pipe(ps.resume());
// ^^ Commenting this line doesn't block gulp.dest() from completing.
});