Gulp src not matching nested directories #2452
Unanswered
webstackdev
asked this question in
Help
Replies: 1 comment
-
Hey @calligraphic, it's fine to post questions in the gulp repo, but we have Discussions enabled now so I'm going to move this over there. As for your question, gulp.src() is a stream and you aren't draining it so I wouldn't expect you to be getting everything. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I posted this on Stack Overflow also, please let me know if I should only post here or only on SO for this kind of question in the future. I can't tell if this is a bug or (more likely) my lack of a clue.
I have these two functions in the same gulpfile:
The single entry in the glob array is intentional. I've been testing with just one but once it works I will add more glob patterns from the project root. I'm using the
forEach
because Gulp'ssrc()
function errors with no warning (even withstrict
on andsilent
off) if there are no matches to the pattern. It's a large project and I have some folders that will not match a pattern until later on.The file structure I'm trying to glob looks like this:
My
debugNodeGlob()
function (usingglob
) returns all of the files I expect. HoweverdebugGulpSrc()
returns the files in the root directory and the root offolder1
, but nothing else. It does not get the files in nested directories. The Gulp src documentation says that it should with the double-star (**
) glob pattern, andglob
on its own does so normally.I
diff
'd thedebug
output set as an option in both approaches, and everything was identical except the output.The only difference I can see (except for many files not returned by Gulp src) is that the files returned by
glob
have absolute paths, and those returned bysrc
have relative paths to the project root:vs.
I am running the script file from here from the command line:
I use the same glob patterns as input to
gulp-watch
, and it works fine and handles nested subdirectories correctly.I have a feeling that Gulp
src
is doing something where it expands my double-star wildcard to every directory actually on the block device, finds one without a match, and dies silently, but I have no idea how to fix that or get the functionality that I need. It's not reasonable to add a new glob pattern to the array every time I add a subdirectory. The double-star glob pattern should handle that (including subfolders that don't have matching files), just like Isaac'sglob
library does (the documentation sayssrc
is a wrapper aroundglob
).I haven't grasped why Gulp doesn't offer an option to continue with the next glob pattern in an array of globs after one doesn't match, and instead chooses to die without emitting an event I could do something with. If it does emit an event, it's not in the documentation and isn't caught with .on(error, fn). If anyone has insight into that design decision I'd appreciate it.
Beta Was this translation helpful? Give feedback.
All reactions