fb3ecf8c by Adam Heath

Always set the requirejs callback, and pass withCoverage into the

builder.
1 parent bb5a3b52
......@@ -421,11 +421,10 @@ module.exports = function (grunt) {
};
})(template.process),
});
if (mpConfig.jasmine.withCoverage) {
var instrumentationCallback = function instrumentationCallback(mpConfigBase) {
/* global requirejs:false */
var oldLoad = requirejs.load;
requirejs.load = function (context, moduleName, url) {
var requireCallback = function requireCallback(mpConfigBase, withCoverage) {
/* global requirejs:false */
requirejs.load = (function(oldLoad) {
return function (context, moduleName, url) {
//console.log('context=' + JSON.stringify(arguments), 'moduleName=' + moduleName, 'url=' + url);
var parts = url.split('/');
for (var i = 0; i < parts.length; ) {
......@@ -446,18 +445,20 @@ module.exports = function (grunt) {
}
}
url = parts.join('/');
if (url.indexOf(mpConfigBase + '/scripts/') === 0) {
if (withCoverage && url.indexOf(mpConfigBase + '/scripts/') === 0) {
url = './.grunt/grunt-contrib-jasmine/' + url;
}
return oldLoad.apply(this, [context, moduleName, url]);
};
};
})(requirejs.load);
};
var stringify = require('node-stringify');
//templateOptions.requireConfig.callback = eval('(' + stringify(callbackBuilder) + ')(' + JSON.stringify(mpConfig.base) + ')');
/*jshint -W054*/
templateOptions.requireConfig.callback = new Function(stringify(instrumentationCallback) + '(' + JSON.stringify(mpConfig.base) + ');');
var stringify = require('node-stringify');
//templateOptions.requireConfig.callback = eval('(' + stringify(callbackBuilder) + ')(' + JSON.stringify(mpConfig.base) + ')');
/*jshint -W054*/
templateOptions.requireConfig.callback = new Function(stringify(requireCallback) + '(' + JSON.stringify(mpConfig.base) + ', ' + mpConfig.jasmine.withCoverage + ');');
if (mpConfig.jasmine.withCoverage) {
templateOptions = {
coverage: 'dist/coverage/coverage.json',
report: 'dist/coverage',
......