【问题标题】:Exclude .spec files minified by grunt-contrib-jshint排除由 grunt-contrib-jshint 缩小的 .spec 文件
【发布时间】:2015-12-09 10:20:45
【问题描述】:

我正在使用 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']
  }
},

【问题讨论】:

    标签: javascript gruntjs grunt-contrib-jshint


    【解决方案1】:

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

    例如!**/*.spec.js

    你的情况

    all: {
        src: [
          '!**/*.spec.js',
          'Gruntfile.js',
          '<%= yeoman.app %>/scripts/{,*/}*.js'
        ]
      },
      test: {
        options: {
          jshintrc: 'test/.jshintrc'
        },
        src: ['!**/*.spec.js','test/spec/{,*/}*.js']
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-05
      • 1970-01-01
      • 2013-12-30
      相关资源
      最近更新 更多