From 009c0b92002fa1aeae985c1a5c8707119a945647 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Tue, 28 May 2013 14:45:12 -0400 Subject: [PATCH] Expose test modules for requirement. --- grunt/config/browserify.js | 4 +++- grunt/tasks/browserify.js | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index ed98282a42..7594e95544 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -90,7 +90,9 @@ var jasmine = { var test = { entries: [ "./build/modules/test/all.js", - "./build/modules/**/__tests__/*-test.js" + ], + requires: [ + "**/__tests__/*-test.js" ], outfile: './build/react-test.js', debug: false, diff --git a/grunt/tasks/browserify.js b/grunt/tasks/browserify.js index b73b67bd19..d43c0841f8 100644 --- a/grunt/tasks/browserify.js +++ b/grunt/tasks/browserify.js @@ -12,7 +12,6 @@ module.exports = function() { // More/better assertions // grunt.config.requires('outfile'); // grunt.config.requires('entries'); - config.requires = config.requires || {}; config.transforms = config.transforms || []; config.after = config.after || []; if (typeof config.after === 'function') { @@ -24,9 +23,20 @@ module.exports = function() { var bundle = browserify(entries); // Make sure the things that need to be exposed are. - // TODO: support a blob pattern maybe? - for (var name in config.requires) { - bundle.require(config.requires[name], { expose: name }); + var requires = config.requires || {}; + if (requires instanceof Array) { + grunt.file.expand({ + nonull: true, // Keep IDs that don't expand to anything. + cwd: "src" + }, requires).forEach(function(name) { + bundle.require("./build/modules/" + name, { + expose: name.replace(/\.js$/i, "") + }); + }); + } else if (typeof requires === "object") { + Object.keys(requires).forEach(function(name) { + bundle.require(requires[name], { expose: name }); + }); } // Extract other options