Skip to content

Commit

Permalink
fix(index.js): resolve promises in the callback
Browse files Browse the repository at this point in the history
  • Loading branch information
felixzapata committed Aug 8, 2016
1 parent 71204cf commit ec8ec54
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
var gutil = require('gulp-util');
var through = require('through2');
var path = require('path');
var fileUrl = require('file-url');
var AxeBuilder = require('axe-webdriverjs');
var WebDriver = require('selenium-webdriver');
Expand All @@ -17,6 +16,16 @@ var url = '';

module.exports = function (options) {

var createResults = function(cb) {
Promise.all(promises).then(function(results) {
fs.writeFileSync(dest, JSON.stringify(results, null, ' '));
driver.quit().then(function() {
cb(result);
});
});
cb();
};

return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
Expand All @@ -41,31 +50,22 @@ module.exports = function (options) {
results.url = url;
results.timestamp = new Date().getTime();
results.time = results.timestamp - startTimestamp;
console.log(results);
resolve(results);
});
});
});

promises.push(promise);

Promise.all(promises).then(function(results) {
fs.writeFileSync(dest, JSON.stringify(results, null, ' '));
driver.quit().then(function() {
cb(result);
});
});

/*driver
.get(fileUrl(file.path))
.then(function () {
AxeBuilder(driver)
.analyze(function (results) {
console.log(results);
});
});*/
createResults(cb);

} catch (err) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, err));
}
});




};

0 comments on commit ec8ec54

Please sign in to comment.