derby-webdriverio
Version:
Webdriver.io for Derby.js
50 lines (44 loc) • 1.72 kB
JavaScript
// Generated by CoffeeScript 1.12.7
(function() {
var Bluebird, natural, nounInflector;
Bluebird = require('bluebird');
natural = require('natural');
nounInflector = new natural.NounInflector();
module.exports = function(webdriverConf, customAfter) {
return function(failures, pid) {
return Bluebird.resolve().then(function() {
return Bluebird.mapSeries(Object.keys(webdriverConf.browsers), function(groupName) {
var amount, j, results, singularName;
amount = webdriverConf.browsers[groupName];
if (amount === 1 || amount === true) {
return global[groupName].end();
} else {
singularName = nounInflector.singularize(groupName);
return Bluebird.mapSeries((function() {
results = [];
for (var j = 0; 0 <= amount ? j < amount : j > amount; 0 <= amount ? j++ : j--){ results.push(j); }
return results;
}).apply(this), function(i) {
return global[groupName].select(singularName + i).end();
});
}
});
}).then(function() {
console.log('Kill Server');
return new Bluebird(function(resolve, reject) {
if (global.__runningServerExited) {
return resolve();
}
global.__runningServer.on('exit', function() {
console.log('Server Exited');
return resolve();
});
console.log('Send kill signal');
return process.kill(-global.__runningServer.pid);
});
}).then(function() {
return typeof customAfter === "function" ? customAfter(failures, pid) : void 0;
});
};
};
}).call(this);