-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
preprocessor.js
44 lines (26 loc) · 981 Bytes
/
preprocessor.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
'use strict';
var preprocessor = require('karma/lib/preprocessor');
var api = ['config.preprocessors', 'config.basePath', 'injector'];
function arrayEquals(a, b) {
return a.join('#') === b.join('#');
}
function getPreprocessorFactory() {
var factory = preprocessor.createPreprocessor;
if (!arrayEquals(factory.$inject, api)) {
console.log('incompatible karma preprocessor: found', factory.$inject, 'expected', api);
throw new Error('incompatible karma preprocessor');
}
return factory;
}
/**
* Monkey patch preprocessors to preprocess *.browserify
*/
var originalFactory = getPreprocessorFactory();
var createPreprocessor = function(config, basePath, injector) {
// add our preprocessor for .browserify files
config['**/*.browserify'] = ['browserify-bundle'];
return originalFactory(config, basePath, injector);
};
createPreprocessor.$inject = api;
// publish patched preprocessor
module.exports.createPreprocessor = createPreprocessor;