【发布时间】:2014-07-08 05:55:53
【问题描述】:
我有一个在 grunt config 中注册的任务:
grunt.registerTask('test_Branches', 'Run Branches check on windows', require('PATH').check);
在我的分支.test.js 中我有方法 check():
this.check = function () {
'use strict';
console.log("Execution started\n");
exec('git for-each-ref --sort=-committerdate refs/remotes/origin/ --format='%(committername)', {cwd: currentDir}, function (error, stdout, stderr) {
console.log('started 1.1');
if (stderr) {
console.log('stderr: ' + stderr + "\n");
}
else {
console.log("Authors has been received\n");
}
if (error !== null) {
console.log('Execution command error: ' + error + "\n");
}
});
};
但是当我试图通过命令行执行我的任务时:
grunt test_Branches
我明白了:
C:\PATH>grunt test_Branches
Running "test_Branches" task
Execution started
Done, without errors.
我的 'exec' 方法有什么问题?
【问题讨论】:
-
看来我找到了解决方案,伙计们!您需要将
grunt.task.current.async();与异步函数一起使用。我也是,现在可以了! -
好的,谢谢,乔纳森。不幸的是,我不知道那件事,浪费了 2 天时间来找到解决方案:(
标签: javascript node.js asynchronous gruntjs exec