I am trying to glob all files&directories with gulp.src()
expcept all directories starting with the character _
(i.e. _Stuff/
). How can I achieve that?
Say you have a folder project/src
that contains the following files:
file.txt
folder
folder/file.txt
folder/_subfolder
folder/_subfolder/file.txt
folder/subfolder
folder/subfolder/file.txt
_folder
_folder/file.txt
_folder/_subfolder
_folder/_subfolder/file.txt
_folder/subfolder
_folder/subfolder/file.txt
Then this task in project/Gulpfile.js
:
gulp.task('default', function() {
return gulp.src([
'src/**/*', //select all files
'!src/**/_*/', //exclude folders starting with '_'
'!src/**/_*/**/*', //exclude files/subfolders in folders starting with '_'
])
.pipe(gulp.dest('dist'));
});
Will result in the following files being written to project/dist
:
file.txt
folder
folder/file.txt
folder/subfolder
folder/subfolder/file.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With