I looked at the source for gulp.src()
, and apparently it's just a reference to require('vinyl-fs').src()
. Looking at the documentation for vfs's src()
, it says that it takes any options that it defines, along "any glob-related options are documented in glob-stream and node-glob." According to node-glob
's documentation, I can pass in the options { sync: true }
.
When I try to use gulp.src(..., { sync: true })
, however, I get this error from gulp:
TypeError: Object #<GlobSync> has no method 'on'
Any idea how to specify sync
option with gulp.src()
?
Still ran into problems using gulp.src(filePatterns).pipe(order(filePatterns))
. The concatenated output order now stays the same everytime I run gulp
, but the order of concatenation isn't in the order specified by the filePatterns
array literal. Maybe I'm missing something.
Whatever the case, I ended up implementing this workaround below. Instead of doing, for example, gulp.src(filePatterns)
, I now do gulp.src(deglob(filePatterns))
and get the same order each time, and in the order that the filePatterns
array literal is defined.
function deglob() {
var syncGlob = require('glob').sync,
patterns = _.flatten(arguments, true);
return _.flatten(patterns.map(function(pattern) {
return syncGlob(pattern).map(function(file) {
return pattern.charAt(0) === '!' ? ('!' + file) : file;
});
}), true);
}
I've actually stopped using gulp.src()
completely and instead use this everywhere:
gulp.from = function () {
return gulp.src(deglob(arguments));
};