-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
40 lines (30 loc) · 1.05 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
var path = require('path');
var pattern = function (file) {
return {pattern: file, included: true, served: true, watched: false};
};
var CHAI_PATH = path.resolve(require.resolve('chai'), '../chai.js');
var IMMUTABLE_PATH = path.resolve(require.resolve('immutable'));
function findDuplicates (files) {
var duplicates = {};
for (var i = 0; i < files.length; i++) {
duplicates.chai = duplicates.chai || files[i].pattern === CHAI_PATH;
duplicates.immutable = duplicates.immutable || files[i].pattern === IMMUTABLE_PATH;
}
return duplicates;
}
var framework = function (files) {
var duplicates = findDuplicates(files);
// chai
if (!duplicates.chai) {
files.push(pattern(CHAI_PATH));
files.push(pattern(path.join(__dirname, 'adapter.js')));
}
// immutable
if (!duplicates.immutable) {
files.push(pattern(IMMUTABLE_PATH));
}
// chai-immutable
files.push(pattern(path.resolve(require.resolve('chai-immutable'))));
};
framework.$inject = ['config.files'];
module.exports = {'framework:chai-immutable': ['factory', framework]};