首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gruntfile.js -任务“默认”未找到

Gruntfile.js -任务“默认”未找到
EN

Stack Overflow用户
提问于 2015-03-19 15:03:39
回答 1查看 3.4K关注 0票数 0

我正在尝试扩展构建在这里的D3日历Viz库:https://github.com/kamisama/cal-heatmap

我克隆了回购。代码使用Grunt作为构建过程,因此我已经在目录中安装了Grunt并运行了npm install。运行grunt我得到一个错误:

代码语言:javascript
复制
Warning: Task "default" not found. Use --force to continue.

我已经将grunt.js文件放入http://esprima.org/demo/validate.html中,并且返回时没有出现任何错误。我搞不懂为什么格特不在这里工作。

下面是grunt.js文件:

代码语言:javascript
复制
module.exports = function(grunt) {

    "use strict";

    var headerComment = "/*! <%= pkg.name %> v<%= pkg.version %> (<%= grunt.template.today() %>)\n" +
                " *  ---------------------------------------------\n" +
                " *  <%= pkg.description %>\n" +
                " *  <%= pkg.homepage %>\n" +

                " *  Licensed under the <%= pkg.license %> license\n" +
                " *  Copyright 2014 <%= pkg.author.name %>\n" +
                " */\n";

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        jshint: {
            options: {
                jshintrc: ".jshintrc"
            },
            lib: {
                src: ["src/<%= pkg.name %>.js"]
            },
            test: {
                options: {
                    jshintrc: "test/.jshintrc"
                },
                src: ["test/test.js", "test/test-amd.js"]
            }
        },
        csslint: {
            base: {
                src: "<%= pkg.name %>.css",
                rules: {
                    "known-properties": false,
                    "box-sizing": false
                }
            }
        },
        uglify: {
            options: {
                banner: headerComment
            },
            base: {
                files: {
                    "<%= pkg.name %>.min.js" : ["<%= pkg.name %>.js"]
                }
            }
        },
        qunit: {
            options: {
                "--web-security": "no",
                coverage: {
                    src: ["src/*.js"],
                    instrumentedFiles: "temp/",
                    htmlReport: "report/coverage",
                    coberturaReport: "report/"
                }
            },
            all: ["test/*.html"]
        },
        concat: {
            options: {
                banner: headerComment + "\n"
            },
            js: {
                src: ["src/<%= pkg.name %>.js"],
                dest: "<%= pkg.name %>.js"
            },
            test: {
                src: ["test/src/function.js", "test/src/**/*.js"],
                dest: "test/test.js"
            }
        },
        coveralls: {
            options: {
                coverage_dir: "coverage/"
            }
        },
        watch: {
            scripts: {
                files: "test/src/**/*.js",
                tasks: ["concat:test"],
                options: {
                    interrupt: true,
                }
            },
            lint: {
                files: "src/*.js",
                tasks: ["jshint:lib"],
                options: {
                    interrupt: true,
                }
            }
        }
    });

    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-uglify");
    grunt.loadNpmTasks("grunt-css");
    grunt.loadNpmTasks("grunt-contrib-qunit");
    grunt.loadNpmTasks("grunt-contrib-concat");
    grunt.loadNpmTasks("grunt-karma-coveralls");
    grunt.loadNpmTasks("grunt-contrib-watch");

    // TO RUN BEFORE COMMIT
    // ====================
    grunt.registerTask("quick-build", ["csslint", "jshint"]);

    // Full build without version bump
    grunt.registerTask("build", ["concat", "qunit", "csslint", "jshint", "uglify"]);

    // FOR TRAVIS
    // ==========
    grunt.registerTask("travis", ["jshint", "csslint"]);
};

下面是package.json文件:

代码语言:javascript
复制
{
  "name": "cal-heatmap",
  "version": "3.5.2",
  "description": "Cal-Heatmap is a javascript module to create calendar heatmap to visualize time series data",
  "keywords": [
    "calendar",
    "graph",
    "d3js",
    "heat map"
  ],
  "main": "cal-heatmap.min.js",
  "directories": {
    "test": "test"
  },
  "dependencies": {
    "d3": ">= v3.0.6"
  },
  "devDependencies": {
    "grunt": "~0.4.5",
    "grunt-contrib-uglify": "~0.7.0",
    "grunt-contrib-copy": "~0.7.0",
    "grunt-contrib-jshint": "~0.11.0",
    "grunt-contrib-concat": "~0.5.0",
    "grunt-contrib-watch": "~0.6.1",
    "grunt-contrib-qunit": "~0.5.2",

    "grunt-css": "~0.5.4",
    "grunt-replace": "~0.8.0",

    "phantomjs": "~1.9.15",
    "karma": "~0.12.31",
    "karma-coverage": "~0.2.7",
    "karma-qunit": "~0.1.4",
    "karma-phantomjs-launcher": "~0.1.4",
    "grunt-karma-coveralls": "~2.5.3",

    "qunitjs": "~1.17.0",
    "jquery": "~1.9.1"
  },
  "scripts": {
    "test": "grunt travis --verbose; ./node_modules/karma/bin/karma start --single-run --browsers PhantomJS"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/kamisama/cal-heatmap.git"
  },
  "homepage": "https://github.com/kamisama/cal-heatmap",
  "author": {
    "name": "Wan Qi Chen",
    "url": "http://www.kamisama.me"
  },
  "license": "MIT",
  "gitHead": "e7bf798c210e0c25df9f6857bdb268001ef67fd1",
  "volo": {
    "dependencies": {
      "d3": "d3"
    }
  },
  "jam": {
    "dependencies": {
      "d3": ">=3.0.6"
    }
  },
  "bugs": "https://github.com/kamisama/cal-heatmap/issues",
  "github": "https://github.com/kamisama/cal-heatmap",
  "categories": [
    "Data",
    "Visualization"
  ]
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-19 15:04:49

您需要定义默认任务,例如下面。

代码语言:javascript
复制
grunt.registerTask("default", [ "lint", "test", "coverage" ]);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29148082

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档