moved the finsished callback to each method call instead of the instance (clean)
This commit is contained in:
parent
b9ac5f5efd
commit
9ee402ad30
|
|
@ -17,14 +17,13 @@ var path = require('path'),
|
|||
|
||||
module.exports = Analyzer;
|
||||
|
||||
function Analyzer(completionCallback) {
|
||||
this.completionCallback = completionCallback;
|
||||
function Analyzer() {
|
||||
}
|
||||
|
||||
Analyzer.prototype.analyze = function(urls, collector, urlAnalysedCallback) {
|
||||
Analyzer.prototype.analyze = function(urls, collector, urlAnalysedCallback, completionCallback) {
|
||||
var self = this;
|
||||
if (urls.length === 0) {
|
||||
self.completionCallback();
|
||||
completionCallback();
|
||||
}
|
||||
|
||||
var tasks = [
|
||||
|
|
@ -94,6 +93,6 @@ Analyzer.prototype.analyze = function(urls, collector, urlAnalysedCallback) {
|
|||
collector.collectPageData(pageData);
|
||||
urlAnalysedCallback(err, url, pageData);
|
||||
});
|
||||
self.completionCallback(undefined);
|
||||
completionCallback(undefined);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ module.exports = Runner;
|
|||
|
||||
function Runner() {
|
||||
var self = this;
|
||||
this.analyzer = new Analyzer(function(err) {
|
||||
self.analysisComplete(err);
|
||||
});
|
||||
this.analyzer = new Analyzer();
|
||||
this.collector = new Collector();
|
||||
this.htmlRenderer = new HTMLRenderer();
|
||||
this.junitRenderer = new JUnitRenderer(this.collector);
|
||||
|
|
@ -46,6 +44,7 @@ Runner.prototype.analysisComplete = function(err) {
|
|||
var junitRenderer = this.junitRenderer;
|
||||
var downloadErrors = this.downloadErrors;
|
||||
var analysisErrors = this.analysisErrors;
|
||||
// function a = this.a;
|
||||
async.parallel({
|
||||
renderSummary: function(cb){
|
||||
htmlRenderer.renderSummary(aggregates,cb);
|
||||
|
|
@ -82,12 +81,13 @@ Runner.prototype.analysisComplete = function(err) {
|
|||
function(err, results) {
|
||||
if (!err)
|
||||
log.log('info', "Wrote results to " + config.run.absResultDir);
|
||||
});
|
||||
// call the callback!
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Runner.prototype.run = function() {
|
||||
|
||||
Runner.prototype.run = function(finshedCb) {
|
||||
finshedCb = finshedCb || function () {};
|
||||
// setup the directories needed
|
||||
fs.mkdirsSync(path.join(config.run.absResultDir, config.dataDir));
|
||||
|
||||
|
|
@ -159,6 +159,7 @@ Runner.prototype.analyzeUrls = function(urls) {
|
|||
var junitRenderer = this.junitRenderer;
|
||||
var htmlRenderer = this.htmlRenderer;
|
||||
var analysisErrors = this.analysisErrors;
|
||||
var self = this;
|
||||
this.analyzer.analyze(urls, this.collector, function(err, url, pageData) {
|
||||
|
||||
if (err) {
|
||||
|
|
@ -171,8 +172,7 @@ Runner.prototype.analyzeUrls = function(urls) {
|
|||
if (config.junit)
|
||||
junitRenderer.renderForEachPage(url, pageData);
|
||||
htmlRenderer.renderPage(url, pageData, function(){});
|
||||
}
|
||||
|
||||
|
||||
);
|
||||
},function(err) {
|
||||
self.analysisComplete(err);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue