mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
5fd4467bf7
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.
47 lines
964 B
JavaScript
47 lines
964 B
JavaScript
'use strict';
|
|
|
|
var grunt = require("grunt");
|
|
var expand = grunt.file.expand;
|
|
var spawn = grunt.util.spawn;
|
|
|
|
module.exports = function() {
|
|
var done = this.async();
|
|
var config = this.data;
|
|
|
|
var args = [
|
|
"--cache-dir", ".module-cache",
|
|
"--relativize",
|
|
"--follow-requires",
|
|
config.sourceDir,
|
|
config.outputDir
|
|
];
|
|
|
|
var rootIDs = expand({
|
|
nonull: true, // Keep IDs that don't expand to anything.
|
|
cwd: "src"
|
|
}, config.rootIDs).map(function(id) {
|
|
return id.replace(/\.js$/i, "");
|
|
});
|
|
|
|
args.push.apply(args, rootIDs);
|
|
args.push("--config" /* from stdin */);
|
|
|
|
var child = spawn({
|
|
cmd: "bin/jsx-internal",
|
|
args: args
|
|
}, function(error, result, code) {
|
|
if (error) {
|
|
grunt.log.error(error);
|
|
done(false);
|
|
} else {
|
|
done();
|
|
}
|
|
});
|
|
|
|
child.stdin.write(JSON.stringify(config.getConfig()));
|
|
child.stdin.end();
|
|
|
|
child.stdout.pipe(process.stdout);
|
|
child.stderr.pipe(process.stderr);
|
|
};
|