Method 'exec' doesn't work in grunt task

女生的网名这么多〃 提交于 2019-12-12 02:04:46

问题


I have a task that registred in grunt config:

grunt.registerTask('test_Branches',          'Run Branches check on windows',       require('PATH').check);

And in my branches.test.js I have method 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");
            }
        });

};

But when I'm trying to execute my task through command line with command:

grunt test_Branches

I got:

C:\PATH>grunt test_Branches
Running "test_Branches" task
Execution started
Done, without errors.

What's the problem with my 'exec' method?


回答1:


The solution for this problem is using grunt.task.current.async(); for asynchronous functions. As Jonathan Lonowski mentioned, here you can find details.



来源:https://stackoverflow.com/questions/24624607/method-exec-doesnt-work-in-grunt-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!