The library for web and native user interfaces.
Use populist v0.1.2 to bundle test modules instead of browserify.
This will allow full support for mocking, dumpCache, and correct line numbers in error messages.
Ben Newman committed
Jul 15, 2013 at 11:34 UTC
c6c4657f83264525ee4f510c2417ae58a7e72a4e
5 files changed
+50
-1
Gruntfile.js
+5
-1
@@ -4,6 +4,7 @@ var exec = require('child_process').exec;
4
var jsxTask = require('./grunt/tasks/jsx');
5
var browserifyTask = require('./grunt/tasks/browserify');
6
var wrapupTask = require('./grunt/tasks/wrapup');
7
+var populistTask = require('./grunt/tasks/populist');
8
var phantomTask = require('./grunt/tasks/phantom');
9
var npmTask = require('./grunt/tasks/npm');
10
var releaseTasks = require('./grunt/tasks/release');
@@ -16,6 +17,7 @@ module.exports = function(grunt) {
17
jsx: require('./grunt/config/jsx/jsx'),
18
browserify: require('./grunt/config/browserify'),
19
wrapup: require('./grunt/config/wrapup'),
20
+ populist: require('./grunt/config/populist'),
21
phantom: require('./grunt/config/phantom'),
22
npm: require('./grunt/config/npm'),
23
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js'],
@@ -44,6 +46,8 @@ module.exports = function(grunt) {
46
// defines global variables instead of using require.
47
grunt.registerMultiTask('wrapup', wrapupTask);
48
49
+ grunt.registerMultiTask('populist', populistTask);
50
+
51
grunt.registerMultiTask('phantom', phantomTask);
52
53
grunt.registerMultiTask('npm', npmTask);
@@ -56,7 +60,7 @@ module.exports = function(grunt) {
60
'jsx:jasmine',
61
'jsx:test',
62
'browserify:jasmine',
59
- 'browserify:test'
63
+ 'populist:test'
64
]);
65
66
grunt.registerTask('test', ['build:test', 'phantom:run']);
grunt/config/populist.js
new
+13
@@ -0,0 +1,13 @@
1
+'use strict';
2
+
3
+var test = {
4
+ args: ["test/all:"],
5
+ requires: [
6
+ "**/__tests__/*-test.js"
7
+ ],
8
+ outfile: './build/react-test.js'
9
+};
10
+
11
+module.exports = {
12
+ test: test
13
+};
grunt/tasks/populist.js
new
+28
@@ -0,0 +1,28 @@
1
+'use strict';
2
+
3
+var grunt = require('grunt');
4
+
5
+module.exports = function() {
6
+ var config = this.data;
7
+ var done = this.async();
8
+
9
+ // create the bundle we'll work with
10
+ var args = config.args;
11
+
12
+ // Make sure the things that need to be exposed are.
13
+ var requires = config.requires || {};
14
+ grunt.file.expand({
15
+ nonull: true, // Keep IDs that don't expand to anything.
16
+ cwd: "src"
17
+ }, requires).forEach(function(name) {
18
+ args.push(name.replace(/\.js$/i, ""));
19
+ });
20
+
21
+ require("populist").buildP({
22
+ rootDirectory: "build/modules",
23
+ args: args
24
+ }).then(function(output) {
25
+ grunt.file.write(config.outfile, output);
26
+ done();
27
+ });
28
+};
package.json
+1
@@ -44,6 +44,7 @@
44
"devDependencies": {
45
"browserify": "~2.24.1",
46
"wrapup": "~0.12.0",
47
+ "populist": "~0.1.2",
48
"grunt-cli": "~0.1.9",
49
"grunt": "~0.4.1",
50
"grunt-contrib-copy": "~0.4.1",
src/test/all.js
+3
@@ -6,6 +6,9 @@ var Ap = Array.prototype;
6
var slice = Ap.slice;
7
var Fp = Function.prototype;
8
9
+var global = Function("return this")();
10
+global.require = require;
11
+
12
if (!Fp.bind) {
13
// PhantomJS doesn't support Function.prototype.bind natively, so
14
// polyfill it whenever this module is required.