gulp-filter is filtering everything
Apparently, this is an error in the documentation that is explained in issue #55 at the Github repository.
The solution in my case is this:
var f = filter(['**', '!src/ToCOptions.js'], {'restore': true});
As the author of the issue explains, a single asterisk only matches files that are not in subdirectories. All of the files for this task are in a subdirectory, so the first pattern didn't match anything and the second pattern didn't have any results to subtract from.
To understand **
, I had to use man bash
on a Linux system and search for globstar since the node-glob documentation makes reference to the Bash implementation:
globstar
If set, the pattern ** used in a pathname expansion context will
match all files and zero or more directories and subdirectories. If the
pattern is followed by a /, only directories and subdirectories match.
I've create a simple example with on("data", function(file){})
just to make your understanding more clear around NodeJS Streams.
gulp.task('js', function() {
return gulp.src("my/js/folder/*.js")
.on("data", function(file){
console.log(file)
// here you can filter all your file depends on name/path/etc.
})
...
do something else
...
the same you can do in gulp.dest method
.pipe(gulp.dest(function(file){
// conditions
...
return "my expected path"/* your expected path for file depends on conditions*/
}))
});
I hope it will help you.
Thanks