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.
This commit is contained in:
Ben Alpert
2013-09-09 17:01:06 -07:00
parent 888cc309e0
commit 5fd4467bf7
7 changed files with 44 additions and 24 deletions
-6
View File
@@ -1,6 +0,0 @@
{
"debug": true,
"constants": {
"__DEV__": true
}
}
+35 -4
View File
@@ -1,13 +1,25 @@
'use strict';
var grunt = require('grunt');
var rootIDs = [
"React",
"ReactTransitionGroup"
];
var getDebugConfig = function() {
return {
"debug": true,
"constants": {
"__VERSION__": grunt.config.data.pkg.version,
"__DEV__": true
}
};
};
var debug = {
rootIDs: rootIDs,
configFile: "grunt/config/jsx/debug.json",
getConfig: getDebugConfig,
sourceDir: "src",
outputDir: "build/modules"
};
@@ -16,7 +28,7 @@ var jasmine = {
rootIDs: [
"all"
],
configFile: debug.configFile,
getConfig: getDebugConfig,
sourceDir: "vendor/jasmine",
outputDir: "build/jasmine"
};
@@ -26,18 +38,37 @@ var test = {
"test/all.js",
"**/__tests__/*.js"
]),
configFile: "grunt/config/jsx/test.json",
getConfig: function() {
return {
"debug": true,
"mocking": true,
"constants": {
"__VERSION__": grunt.config.data.pkg.version,
"__DEV__": true
}
};
},
sourceDir: "src",
outputDir: "build/modules"
};
var release = {
rootIDs: rootIDs,
configFile: "grunt/config/jsx/release.json",
getConfig: function() {
return {
"debug": false,
"constants": {
"__VERSION__": grunt.config.data.pkg.version,
"__DEV__": false
}
};
},
sourceDir: "src",
outputDir: "build/modules"
};
module.exports = {
debug: debug,
jasmine: jasmine,
-6
View File
@@ -1,6 +0,0 @@
{
"debug": false,
"constants": {
"__DEV__": false
}
}
-7
View File
@@ -1,7 +0,0 @@
{
"debug": true,
"mocking": true,
"constants": {
"__DEV__": true
}
}
+4 -1
View File
@@ -24,7 +24,7 @@ module.exports = function() {
});
args.push.apply(args, rootIDs);
args.push("--config", config.configFile);
args.push("--config" /* from stdin */);
var child = spawn({
cmd: "bin/jsx-internal",
@@ -38,6 +38,9 @@ module.exports = function() {
}
});
child.stdin.write(JSON.stringify(config.getConfig()));
child.stdin.end();
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
};
+1
View File
@@ -19,6 +19,7 @@
"unused": "vars",
"globals": {
"__VERSION__": false,
"__DEV__": false,
"require": false,
"module": false,
+4
View File
@@ -50,4 +50,8 @@ var React = {
isValidComponent: ReactComponent.isValidComponent
};
// Version exists only in the open-source version of React, not in Facebook's
// internal version.
React.version = __VERSION__;
module.exports = React;