-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·43 lines (34 loc) · 1.06 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var Q = require('q');
module.exports = function(config) {
var logger = config.logger || {
log: console.log,
debug: console.log
}
if (config.debug === false) {
logger.debug = () => (true);
}
var framework = (config) ? config.framework : undefined;
var sauce = require('./tasks/saucelabs')(logger, config)
var callbackDone = function(deferred) {
return function(passed) {
if (config && typeof config.onTestSuiteComplete === 'function'){
config.onTestSuiteComplete(passed)
}
deferred.resolve();
}
}
var callbackExcept = function(deferred) {
return function() {
if (config && typeof config.onException === 'function'){
config.onException()
}
deferred.resolve();
}
}
if(!framework) {
throw new Error('Framework not specified.')
}
var deferred = Q.defer();
sauce(framework, callbackDone(deferred), callbackExcept(deferred))
return deferred.promise;
}