NodeJS - Grunt - 是否可以在NodeJs运行时运行Grunt任务?

时间:2014-07-14 12:37:48

标签: javascript node.js express gruntjs

我在express.js中有一个小应用程序,我想在客户端请求时运行一个名为" build"的Grunt任务,但我不知道如何通过子任务配置到Grunt模块。

executeTask : function (components) {
    // Other stuff
    this.grunt = require("grunt");
    components = components.join();
    var file = require(this.parentDir + "/myProjectFolder/Gruntfile.js")(this.grunt);
    this.grunt.option('target', components);
    var result = this.grunt.task.run(["build"]);

    console.log(result);

    // Other stuff
},

此代码不会产生任何错误但不起作用,输出文件不会生成。 此子任务从CLI正确执行,并引用相同的Gruntfile.js

0 个答案:

没有答案