UNPKG

981 BJavaScriptView Raw
1var path = require('path');
2var _ = require('lodash');
3
4var pattern = function(file) {
5 return {pattern: file, included: true, served: true, watched: false};
6};
7
8var endsWith = function(substr) {
9 return function(str) {
10 return str.indexOf(substr) === (str.length - substr.length);
11 };
12};
13
14var framework = function(files) {
15 var sinonPath = path.resolve(require.resolve('sinon'), '../../pkg/sinon.js');
16 if (!_(files).map('pattern').find(endsWith(path.relative(__dirname, sinonPath)))) {
17 files.unshift(pattern(sinonPath));
18 }
19
20 var chaiPath = path.resolve(require.resolve('chai'), '../chai.js');
21 if (!_(files).map('pattern').find(endsWith(path.relative(__dirname, chaiPath)))) {
22 files.unshift(pattern(chaiPath));
23 files.push(pattern(path.join(__dirname, 'chai-adapter.js')));
24 }
25
26 files.push(pattern(path.resolve(require.resolve('sinon-chai'))));
27};
28
29framework.$inject = ['config.files'];
30module.exports = {'framework:sinon-chai': ['factory', framework]};