使用模式gulp按文件名排除文件

时间:2017-09-28 13:11:11

标签: javascript gulp

我想用gulp排除包含“.fixtures.js”,“。mock.js”或“.tests.js”的文件。例如,我有:

client/js/app.js  
client/js/modules/services/myservice.js
client/js/modules/services/tests/myservice.tests.js
client/js/modules/directives/mydirective.js
client/js/modules/services/tests/mydirective.tests.js
client/js/modules/tests/global.mocks.js
client/js/modules/tests/global.fixtures.js

如何在不手动执行的情况下排除这些内容:

gulp.src([
   'client/js/**/*.js',
   '!client/js/**/*.tests.js',
   '!client/js/**/*.fixtures.js',
   '!client/js/**/*.mocks.js',
])
.pipe(doSomething())

1 个答案:

答案 0 :(得分:3)

基本上是exclude a set of files的副本。

gulp.src([ 'client/js/**/!(*.tests|*.fixtures|*.mocks)*.js' ])

看起来像你想要的。