forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsx.js
More file actions
48 lines (40 loc) · 1.01 KB
/
jsx.js
File metadata and controls
48 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
var path = require('path');
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',
'--use-provides-module',
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');
var child = spawn({
cmd: 'node',
args: [path.join('bin', 'jsx-internal')].concat(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);
};