The library for web and native user interfaces.
Add React.version
getConfig needs to be a function because grunt.config.data.pkg.version isn't available at the time that grunt/config/jsx/jsx.js is required. Test Plan: grunt build, grunt lint, grunt test all work. After building, both react.js and react.min.js contain the version number.
Ben Alpert committed
Jul 16, 2013 at 20:38 UTC
7be14d81552e8097eee6ed21a048fa23d4fce596
7 files changed
+41
-24
grunt/config/jsx/debug.json
deleted
-6
@@ -1,6 +0,0 @@
1
-{
2
- "debug": true,
3
- "constants": {
4
- "__DEV__": true
5
- }
6
-}
grunt/config/jsx/jsx.js
+35
-4
@@ -1,12 +1,24 @@
1
'use strict';
2
3
+var grunt = require('grunt');
4
+
5
var rootIDs = [
6
"React"
7
];
8
9
+var getDebugConfig = function() {
10
+ return {
11
+ "debug": true,
12
+ "constants": {
13
+ "__VERSION__": grunt.config.data.pkg.version,
14
+ "__DEV__": true
15
+ }
16
+ };
17
+};
18
+
19
var debug = {
20
rootIDs: rootIDs,
9
- configFile: "grunt/config/jsx/debug.json",
21
+ getConfig: getDebugConfig,
22
sourceDir: "src",
23
outputDir: "build/modules"
24
};
@@ -15,7 +27,7 @@ var jasmine = {
27
rootIDs: [
28
"all"
29
],
18
- configFile: debug.configFile,
30
+ getConfig: getDebugConfig,
31
sourceDir: "vendor/jasmine",
32
outputDir: "build/jasmine"
33
};
@@ -25,18 +37,37 @@ var test = {
37
"test/all.js",
38
"**/__tests__/*.js"
39
]),
28
- configFile: "grunt/config/jsx/test.json",
40
+ getConfig: function() {
41
+ return {
42
+ "debug": true,
43
+ "mocking": true,
44
+ "constants": {
45
+ "__VERSION__": grunt.config.data.pkg.version,
46
+ "__DEV__": true
47
+ }
48
+ };
49
+ },
50
sourceDir: "src",
51
outputDir: "build/modules"
52
};
53
54
+
55
var release = {
56
rootIDs: rootIDs,
35
- configFile: "grunt/config/jsx/release.json",
57
+ getConfig: function() {
58
+ return {
59
+ "debug": false,
60
+ "constants": {
61
+ "__VERSION__": grunt.config.data.pkg.version,
62
+ "__DEV__": false
63
+ }
64
+ };
65
+ },
66
sourceDir: "src",
67
outputDir: "build/modules"
68
};
69
70
+
71
module.exports = {
72
debug: debug,
73
jasmine: jasmine,
grunt/config/jsx/release.json
deleted
-6
@@ -1,6 +0,0 @@
1
-{
2
- "debug": false,
3
- "constants": {
4
- "__DEV__": false
5
- }
6
-}
grunt/config/jsx/test.json
deleted
-7
@@ -1,7 +0,0 @@
1
-{
2
- "debug": true,
3
- "mocking": true,
4
- "constants": {
5
- "__DEV__": true
6
- }
7
-}
grunt/tasks/jsx.js
+4
-1
@@ -24,7 +24,7 @@ module.exports = function() {
24
});
25
26
args.push.apply(args, rootIDs);
27
- args.push("--config", config.configFile);
27
+ args.push("--config" /* from stdin */);
28
29
var child = spawn({
30
cmd: "bin/jsx",
@@ -38,6 +38,9 @@ module.exports = function() {
38
}
39
});
40
41
+ child.stdin.write(JSON.stringify(config.getConfig()));
42
+ child.stdin.end();
43
+
44
child.stdout.pipe(process.stdout);
45
child.stderr.pipe(process.stderr);
46
};
src/.jshintrc
+1
@@ -19,6 +19,7 @@
19
"unused": "vars",
20
21
"globals": {
22
+ "__VERSION__": false,
23
"__DEV__": false,
24
"require": false,
25
"module": false,
src/core/React.js
+1
@@ -30,6 +30,7 @@ var ReactDefaultInjection = require('ReactDefaultInjection');
30
ReactDefaultInjection.inject();
31
32
var React = {
33
+ version: __VERSION__,
34
DOM: ReactDOM,
35
PropTypes: ReactPropTypes,
36
initializeTouchEvents: function(shouldUseTouch) {