Search code examples
gulp

Gulp - copy folders except


I want to copy my vendor folders (and more) but without specific one's example phpunit.

How can I do that?

I tried this but doesn't work:

return gulp.src(['!vendor/phpunit',  'config/**/*',
'public/**/*',  'src/**/*',  'vendor/**/*'], {"base": "."})
.pipe(gulp.dest(path));

Solution

  • Gulp always performs the negations in gulp.src() last no matter the order they are listed. See glob negations performed last. So you should reorder your gulp.src so that

    '!vendor/phpunit'

    is last. You real issue as you point out is that you need

    '!vendor/phpunit/**/*'

    But the information about the glob negation order is not well-known and trips up a lot of people who aren't expecting it so I'll note it here. In your case, simply making your change in the old order may have worked fine.