Skip to content

Commit

Permalink
chore: merge2 does not work in gulp 5
Browse files Browse the repository at this point in the history
  • Loading branch information
3cp committed Aug 10, 2024
1 parent ef9275f commit d2d82a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 16 additions & 3 deletions dumber/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const babel = require('gulp-babel');
const typescript = require('gulp-typescript');
// @endif
const plumber = require('gulp-plumber');
const merge2 = require('merge2');
const terser = require('gulp-terser');
const gulpif = require('gulp-if');
const del = require('del');
Expand All @@ -30,6 +29,20 @@ const postcssUrl = require('postcss-url');
// @if jasmine || mocha
const gulpRun = require('gulp-run');
// @endif
const { PassThrough } = require('stream');
const mergeStreams = (...streams) => {
const pass = new PassThrough({ objectMode: true });
const { length } = streams;
let ended = 0;
for (let stream of streams) {
stream.on('end', () => {
ended += 1;
if (ended === length) pass.end();
})
stream.pipe(pass, { end: false });
}
return pass;
}

const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
Expand Down Expand Up @@ -124,7 +137,7 @@ function buildJs(src) {
// @endif
return gulp.src(src, { sourcemaps: !isProduction })
.pipe(gulpif(!isProduction && !isTest, plumber()))
.pipe(au2())
.pipe(au2({ hmr: false }))
// @if babel
.pipe(babel());
// @endif
Expand Down Expand Up @@ -183,7 +196,7 @@ function build() {
// dumber knows nothing about .ts/.less/.scss/.md files,
// gulp-* plugins transpiled them into js/css/html before
// sending to dumber.
return merge2(
return mergeStreams(
gulp.src('src/**/*.json'),
// @if babel
// @if !jasmine && !mocha
Expand Down
1 change: 0 additions & 1 deletion dumber/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"gulp-typescript": "^5.0.1",
// @endif
"gulp-plumber": "^1.2.1",
"merge2": "^1.4.1",
"gulp-terser": "^2.1.0",
"gulp-if": "^3.0.0",
"del": "^6.1.1",
Expand Down

0 comments on commit d2d82a3

Please sign in to comment.