src() doesn't work with wildcards (4.0.2 -> 5.0.0)
What were you expecting to happen?
all html files in src/html/**/*.html to be in the dist/ directory
What actually happened?
none of the files were in the dist/ dir
Please give us a sample of your gulpfile
gulp.task("build-html", async function () {
return gulp
.src("src/html/**/*.html")
.pipe(
fileinclude({
context: layout,
prefix: "@@",
basepath: "@file",
indent: true,
})
)
.pipe(gulp.dest("dist"));
});
Terminal output / screenshots
$ yarn gulp build-html
$ ls dist/
Please provide the following information:
- OS & version: Ubuntu 22.04.4 (WSL 2)
- node version: 22.0.0
- npm version: 9.6.4
- gulp version: 5.0.0
Additional information
When using 4.0.2, the program works as expected. So the current solution is downgrading the gulp version.
i have the same issue its copy part of file
What happens if you remove async on your function? You can't combine promise-returning and stream-returning functions.
What happens if you remove
asyncon your function? You can't combine promise-returning and stream-returning functions.
this happens: [15:34:34] The following tasks did not complete: build-html [15:34:34] Did you forget to signal async completion? error Command failed with exit code 1.
(i accidentally closed the issue)
Sounds like your fileinclude plugin is broken, maybe it is emitting an error that's being lost.
Gulp 5 changed the underlying stream implementation and misbehaving stream implementations aren't supported anymore.
I tested and the error still occurs when I remove fileInclude:
Also, it runs normally when using the callback (but still doesn't include all glob matching files)
I have the exact same issue coming from 4.0.2. Using a simple src to dest stream fails with "Did you forget to signal async completion?" when using a wildcard.
Works: gulp.src('src/index.html')
Fails: gulp.src('src/*.html')
I have the same issue, I started migrating to gulp v5 and faced this.
gulp: v5.0.0
node: v20.14.0
npm: 10.7.0
macOS: 14.6.1 Sonoma
Also getting this with Gulp 5, downgrading to version 4 and it seems to work ok:
yarn add gulp@4
I’m encountering a similar issue with what seems like the simplest, most “basic” task Gulp could be asked to perform. I hate to even bring it up, but....
Working code:
gulp.src('src/scss/main.scss')
Failing code:
gulp.src('src/scss/**/*.scss')
Yes, that’s right: just a humble attempt to match multiple .scss files in a directory. Is there something that Gulp 5 has against the **/*.scss pattern? This feels so "elemental" that it almost hurts to ask.
Any pointers would be appreciated. I’m really hoping this is just something obvious that I’m overlooking.
Having upgraded from 4.0.2 to 5.0.0, I've also started seeing issues with this minimal Gulp task:
async function copy() {
return gulp
.src("wwwroot/lib/library1/folder1/**/*.{ttf}", {
base: "wwwroot/lib/library1",
})
.pipe(gulp.dest("wwwroot/dist"));
}
No files are copied and I triple checked they are in the source folder. If I remove the wildcards and explicity state the folder and file names, it copies over to the dist folder just fine.
Any workarounds that will still allow me to use wildcards?
"npm": "^10.9.2"
node v21.6.0
I'm having trouble getting this to work after upgrading from gulp 4.0.2 to 5.0.0. The examples in the documentation do not include an async implementation, so they are useless.
[14:02:19] The following tasks did not complete: default
Did you forget to signal async completion?
With this simple task:
const { src, dest } = require('gulp');
const rename = require('gulp-rename');
const sass = require('gulp-sass')(require('sass'));
exports.default = function () {
return src('./public/src/css/application.scss')
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(rename({ extname: '.min.css' }))
.pipe(dest('public/dist/'));
}
I'm experiencing the same issue in Gulp 5, even though everything works perfectly in Gulp 4. I can't believe such a basic functionality as wildcards is broken! I spent the entire day debugging my code, only to finally discover this thread and realize I'm not the only one facing this problem. For now, I've reverted back to Gulp 4 until this is resolved.
Hi, does anyone know any other workaround other than downgrading? We are intentionally upgrading to address some issues
Can anyone experiencing this issue provide details about their environment? The bare minimum when reporting bugs like this are your node version, output of npm ls, gulpfile code, etc.? This isn't something anyone can reproduce easily (otherwise we would be seeing thousands and thousands of reports, everyone uses gulp.src with globs) and there hasn't been a common denominator sent in so far with all of these comments. Seriously the "wtf?? how is something so basic broken???" comments are just a waste of space in these threads and distract from the actual problem solving some of us need to do.
So far it seems like this has been seen on:
- Ubuntu 22.04.4 (WSL 2) with node 22
- macos 14 with node 20
I believe this was related to https://github.com/gulpjs/glob-stream/pull/136 which we've fixed in https://github.com/gulpjs/gulp/pull/2839 and released as gulp v5.0.1
Can you please upgrade and test it out?
Same thing, simplest src-to-dest example task crash on a glob with a wildcard, doesn't crash on a singular glob.
node v14.21.3 npm v6.14.18
And yes, @phated, I'm still seeing this on gulp v5.0.1.
Following advice by @yocontra not to wtf and rather to be constructive, I've played with my gulpfile, removing stuff until the issue goes away, and found the culprit.
After I comment
cssmin = require('gulp-cssmin')
, the issue goes away. Meaning that simple act of requiring gulp-cssmin breaks gulp.
My gulp-cssmin is v0.1.7. Updating gulp-cssmin to v0.2.0, it's "latest" version, doesn't help, the issue persists.
Additionally, this package is in somewhat broken state, check out its page on npm https://www.npmjs.com/package/gulp-cssmin. Link to github https://github.com/chilijung/gulp-cssmin gives you 404. Funnily enough there is another gulp-cssmin on github https://github.com/pdehaan/gulp-cssmin with same @chilijung in contributors list, but it doesn't have v0.2.0 version which is listed on npm.
So, all affected people should try to remove gulp-cssmin from gulpfile and see if the issue persists.
Next I tried gulp-clean-css as a substitute for gulp-cssmin. Seems to work good, it does its minifying job. In addition to that, the substitution was seamless, gulp-clean-css accepted the same very options that my gulp-cssmin used.