forked from angular-translate/angular-translate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.util.conf.js
45 lines (41 loc) · 1.21 KB
/
karma.util.conf.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
44
45
'use strict';
var fs = require('fs');
var AVAILABLE_SCOPES = [], isValidScope, injectByScope, getAffectiveScope, log, isDefaultScope;
(function(undefined){
AVAILABLE_SCOPES = fs.readdirSync('./test_scopes').filter(function (filename) {
return filename[0] !== '.';
});
isValidScope = function (scope) {
return AVAILABLE_SCOPES.indexOf(scope) > -1;
};
getAffectiveScope = function (scope) {
if (isValidScope(scope)) {
return scope;
} else {
return '(default)';
}
};
injectByScope = function (scope, path) {
var prefix = '';
// unless a scope is given, use the default resources
if (scope && isValidScope(scope)) {
prefix = 'test_scopes/' + scope + '/';
}
return prefix + 'bower_components/' + path;
},
log = function (scope) {
console.log('Available test scopes: ', AVAILABLE_SCOPES);
console.log('Currently selected scope: ', getAffectiveScope(scope));
},
isDefaultScope = function (scope) {
return !isValidScope(scope);
};
})();
module.exports = {
AVAILABLE_SCOPES: AVAILABLE_SCOPES,
isValidScope: isValidScope,
injectByScope: injectByScope,
getAffectiveScope: getAffectiveScope,
isDefaultScope: isDefaultScope,
log: log
};