我正在使用 yeoman Angular 生成器。在此生成器中,测试被放置在单独的文件夹'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']
}
},
最佳答案
在表达式前面使用 !
可忽略它:
例如:!**/*.spec.js
就您而言:
all: {
src: [
'!**/*.spec.js',
'Gruntfile.js',
'<%= yeoman.app %>/scripts/{,*/}*.js'
]
},
test: {
options: {
jshintrc: 'test/.jshintrc'
},
src: ['!**/*.spec.js','test/spec/{,*/}*.js']
}
关于javascript - 排除由 grunt-contrib-jshint 缩小的 .spec 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34176275/