[英]Run Grunt tasks in Node
I'd like to know how is possible to run in a node.js file a task for grunt. 我想知道如何在node.js文件中运行grunt的任务。
I defined a task that works like that: 我定义了一个像这样工作的任务:
grunt backup --option1=sourceFolder --option2=destFolder
If I run it on CMD, all works fine. 如果我在CMD上运行它,一切正常。
But in the moment I try to run it in a node.js file, where there is an instruction like 但是此刻我尝试在node.js文件中运行它,其中有一个类似的指令
var sourceFolder = __dirname + "\\" + process.argv[2];
var destFolder = __dirname + "\\"+ process.argv[3];
...other things...
exec("grunt backup --option1=" + sourceFolder + " --option2=" + destFolder);
happens this: 这发生在:
Running "copy:backup:grunt.option("option1"):grunt.option("option2")" (copy) task... 运行“copy:backup:grunt.option(”option1“):grunt.option(”option2“)”(复制)任务...
Why this happens? 为什么会这样? And there is a smater way in nodeJS instead of this ugly exec?
在nodeJS中有一种更为强硬的方式而不是这个丑陋的exec?
Thanks in advance! 提前致谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.