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) { ...@@ -421,11 +421,10 @@ module.exports = function (grunt) {
421 }; 421 };
422 })(template.process), 422 })(template.process),
423 }); 423 });
424 if (mpConfig.jasmine.withCoverage) { 424 var requireCallback = function requireCallback(mpConfigBase, withCoverage) {
425 var instrumentationCallback = function instrumentationCallback(mpConfigBase) {
426 /* global requirejs:false */ 425 /* global requirejs:false */
427 var oldLoad = requirejs.load; 426 requirejs.load = (function(oldLoad) {
428 requirejs.load = function (context, moduleName, url) { 427 return function (context, moduleName, url) {
429 //console.log('context=' + JSON.stringify(arguments), 'moduleName=' + moduleName, 'url=' + url); 428 //console.log('context=' + JSON.stringify(arguments), 'moduleName=' + moduleName, 'url=' + url);
430 var parts = url.split('/'); 429 var parts = url.split('/');
431 for (var i = 0; i < parts.length; ) { 430 for (var i = 0; i < parts.length; ) {
...@@ -446,18 +445,20 @@ module.exports = function (grunt) { ...@@ -446,18 +445,20 @@ module.exports = function (grunt) {
446 } 445 }
447 } 446 }
448 url = parts.join('/'); 447 url = parts.join('/');
449 if (url.indexOf(mpConfigBase + '/scripts/') === 0) { 448 if (withCoverage && url.indexOf(mpConfigBase + '/scripts/') === 0) {
450 url = './.grunt/grunt-contrib-jasmine/' + url; 449 url = './.grunt/grunt-contrib-jasmine/' + url;
451 } 450 }
452 return oldLoad.apply(this, [context, moduleName, url]); 451 return oldLoad.apply(this, [context, moduleName, url]);
453 }; 452 };
453 })(requirejs.load);
454 }; 454 };
455 455
456 var stringify = require('node-stringify'); 456 var stringify = require('node-stringify');
457 //templateOptions.requireConfig.callback = eval('(' + stringify(callbackBuilder) + ')(' + JSON.stringify(mpConfig.base) + ')'); 457 //templateOptions.requireConfig.callback = eval('(' + stringify(callbackBuilder) + ')(' + JSON.stringify(mpConfig.base) + ')');
458 /*jshint -W054*/ 458 /*jshint -W054*/
459 templateOptions.requireConfig.callback = new Function(stringify(instrumentationCallback) + '(' + JSON.stringify(mpConfig.base) + ');'); 459 templateOptions.requireConfig.callback = new Function(stringify(requireCallback) + '(' + JSON.stringify(mpConfig.base) + ', ' + mpConfig.jasmine.withCoverage + ');');
460 460
461 if (mpConfig.jasmine.withCoverage) {
461 templateOptions = { 462 templateOptions = {
462 coverage: 'dist/coverage/coverage.json', 463 coverage: 'dist/coverage/coverage.json',
463 report: 'dist/coverage', 464 report: 'dist/coverage',
......