0

我正在使用 yeoman 角度发生器。在这个生成器中,测试被放置在一个单独的文件夹'test'中。我宁愿将它们保存在与我的 .js 文件相同的文件夹中。我给他们起名字.spec.js。我需要在我的Gruntfile.js文件中修复此问题,以便它们不包含在缩小、jshint 等中。

无论如何我可以排除以 .spec.js 结尾的文件吗?

// Make sure there are no obvious mistakes
jshint: {
  options: {
    jshintrc: '.jshintrc',
    reporter: require('jshint-stylish')
  },
  all: {
    src: [
      'Gruntfile.js',
      '<%= yeoman.app %>/scripts/{,*/}*.js'
    ]
  },
  test: {
    options: {
      jshintrc: 'test/.jshintrc'
    },
    src: ['test/spec/{,*/}*.js']
  }
},
4

1 回答 1

1

在表达式前面使用!以忽略它:

例如!**/*.spec.js

在你的情况下

all: {
    src: [
      '!**/*.spec.js',
      'Gruntfile.js',
      '<%= yeoman.app %>/scripts/{,*/}*.js'
    ]
  },
  test: {
    options: {
      jshintrc: 'test/.jshintrc'
    },
    src: ['!**/*.spec.js','test/spec/{,*/}*.js']
  }
于 2015-12-09T11:20:34.443 回答