async.each在完成所有迭代后callback

现在我已经一头撞在这段代码上几个小时了。 而且我之前多次使用过“ async.each ”。 可能是代码只是需要一组不同的眼睛来工作。 这是代码和问题。

async.each(process.argv, function(file, callback){ runFile(file, callback); }, function(err){ console.log("Here is the error!:" + err +"files to unstage: " + filesToUnstage) if(err) console.log(err); else{ if(filesToUnstage) { __unstage(); } } }); 

RUNFILE:

 function runFile(filename, callback) { // Do a bunch of stuff .... __parseOutput(output, callback); } 

__parseOutput:

 function __parseOutput(output, callback){ //Do some if else statement and do console.log return callback(null); } 

问题:在所有迭代完成后,不会调用async.each的最后一个callbackfunction(err){..}

所有的问题都是由在callback之间调用的asynchronous方法引起的。 我等待这个有问题的函数完成,然后调用callback 。 在我的情况下,我使用async.waterfall等待,因为我必须从一个值传递给另一个。 对于类似的问题,请阅读这个问题的意见,特别是@Gepser