Glob忽略模式似乎并不是与吞咽有关

时间:2022-02-17 19:51:52

I have an AngularJS project with Karma-run Jasmine unit tests and am trying to use Gulp as my task automator. I have the test spec files alongside the other concept files as prescribed by the JohnPapa Angular 1 style guide.

我有一个AngularJS项目和karma运行的Jasmine单元测试,我正在尝试使用Gulp作为我的任务自动化程序。我有测试规范文件和其他概念文件,按照JohnPapa角1风格指南的规定。

I am trying to ignore the *.spec.js files in my application concatenation step using glob's ignore option to prevent including the test code in the distributed app file but it's not working.

我试图忽略*.spec。在我的应用程序连接步骤中,js文件使用glob的忽略选项来防止在分布式应用程序文件中包含测试代码,但它不起作用。

gulp.task('js:concat:application', function() {
  return gulp.src([
    our.js + 'app.js',
    our.js + '**/*.module.js',
    our.js + '**/*.js'
  ], { ignore: ['**/*.spec.js'] })
    .pipe(concat('application.js'))
    .pipe(gulp.dest(our.built.js));
});

I've tried '*.spec.js', '**/*.spec.js', and 'spec.js', and the same values but as the only value in an array as shown above.

我试着‘* .spec。js”、“* * / * .spec。和'spec.js'以及相同的值,但作为数组中的唯一值,如上面所示。

gulp.src's documentation says that node-glob's options (which includes the ignore option) are supported, but adding them how the documentation describes doesn't appear to be working. At this point, I'm not sure why it's not working.

饮而尽。src的文档说明,node-glob的选项(包括忽略选项)得到了支持,但是添加文档描述的方式似乎并不起作用。在这一点上,我不知道为什么它不起作用。

Versions:

版本:

  • gulp CLI: 1.2.2
  • 吞咽CLI:1.2.2
  • gulp Local version: 3.9.1
  • 杯本地版本:3.9.1
  • node: 6.9.2
  • 节点:6.9.2

1 个解决方案

#1


2  

You can exclude specific files in gulp.src by prepending an exclamation mark to the pattern as indicated in the glob documentation.

您可以在gulp中排除特定的文件。src通过在模式前面加上感叹号,如glob文档所示。

gulp.task('js:concat:application', function() {
  return gulp.src([
    our.js + 'app.js',
    our.js + '**/*.module.js',
    our.js + '**/*.js',
    '!**/*.spec.js'])
    .pipe(concat('application.js'))
    .pipe(gulp.dest(our.built.js));
});

#1


2  

You can exclude specific files in gulp.src by prepending an exclamation mark to the pattern as indicated in the glob documentation.

您可以在gulp中排除特定的文件。src通过在模式前面加上感叹号,如glob文档所示。

gulp.task('js:concat:application', function() {
  return gulp.src([
    our.js + 'app.js',
    our.js + '**/*.module.js',
    our.js + '**/*.js',
    '!**/*.spec.js'])
    .pipe(concat('application.js'))
    .pipe(gulp.dest(our.built.js));
});