Grunt具有相同模块的多个任务不会运行

时间:2017-02-28 17:25:12

标签: javascript node.js gruntjs

我当前的gruntfile如下所示:

'use strict';

module.exports = function( grunt ) {
  require('time-grunt')( grunt );

  grunt.initConfig({
    vNo: 'v1',
    pkg: grunt.file.readJSON('package.json'),
    filepath: '',
    directory: ''
  });

  grunt.loadTasks('grunt/tasks');
  grunt.loadTasks('grunt/configs');
};

当我运行grunt scsslint时,它运行正常。

module.exports = function( grunt ) {
  grunt.config('scsslint', {
    options: {
      configFile: '.scss-lint.yml',
      reporterOutput: 'scss-lint-report.xml',
      colorizeOutput: true,
      maxBuffer: 30000000000000000000 * 1024
    },
    src: ['src/bbtcom/_assets/scss/**/*']
  });

  grunt.loadNpmTasks('grunt-scss-lint');
};

如果我尝试运行grunt scsslintCalcs,我会收到错误,

Warning: Task "scsslintCalcs" not found. Use --force to continue.
Error: Task "scsslintCalcs" not found.
at Task.run (/Users/Development/project/node_modules/grunt/lib/util/task.js:179:28)
at /Users/Development/project/node_modules/grunt/lib/grunt.js:161:39
at Array.forEach (native)
at Object.grunt.tasks (/Users/Development/projecy/node_modules/grunt/lib/grunt.js:161:9)
at Object.module.exports [as cli] (/Users/Development/project/node_modules/grunt/lib/grunt/cli.js:38:9)
at Object.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:44:20)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)

但我的scsslintCalcs.js

module.exports = function( grunt ) {
  grunt.config('scsslintCalcs', {
    options: {
      configFile: '.scss-lint.yml',
      reporterOutput: 'scss-lint-report-calcs.xml',
      colorizeOutput: true,
      maxBuffer: 30000000000000000000 * 1024
    },
    src: ['src/leadfusion/*.scss']
  });

  grunt.loadNpmTasks('grunt-scss-lint');
};

所以我不确定为什么scsslint有效,但其余部分无效。

对于出了什么问题的任何见解?

我已经尝试从任务中删除grunt.loadNpmTasks('grunt-scss-lint');,甚至将它们重命名为scsslint,但保留文件我需要的东西没有运气

1 个答案:

答案 0 :(得分:0)

原来我没有像我想象的那样注册任务。

grunt.registerTask('scsslintCalcs', function () {});