I'm trying to upgrade from gulp 3.9.1 to gulp 4.0.0 but my gulpfile is breaking on gulp.src when there are no files matched.
I can fix this by adding the allowEmpty: true option, which appears to be new in gulp 4.
My question is, did gulp 3 allow empty matches by default?
If the answer is yes then the behaviour of gulp.src has changed between gulp 3 and gulp 4, and I think this should be documented somewhere. If it is not in the documentation, I am happy to submit a PR.
Yes and it's documented.
https://gulpjs.com/docs/en/api/src#errors
When the globs argument can only match one file (such as foo/bar.js) and no match is found, throws an error with the message, "File not found with singular glob". To suppress this error, set the allowEmpty option to true.
When an invalid glob is given in globs, throws an error with the message, "Invalid glob argument".
Thanks for linking that documentation.
But I'm still not clear on whether the behaviour is actually different from Gulp 3.
If it is different, the linked documentation doesn't say so. I think it should because anyone upgrading from Gulp 3 will be experiencing their gulpfile breaking on gulp.src and will be wondering why.
The gulp 4 docs aren't written from the perspective of people upgrading. They are the source of truth for that version. Perhaps you've seen our open issue for a Migration Guide?
Ok that makes sense. I'll have a look at the migration guide issue. Thank you.
Most helpful comment
Yes and it's documented.
https://gulpjs.com/docs/en/api/src#errors