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
|
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -103,13 +103,16 @@
}
function buildMin(output, done) {
- var cc = require('closure-compiler');
- var options = {
- compilation_level: 'ADVANCED_OPTIMIZATIONS',
- output_wrapper: '(function() {%output%})();'
- };
- grunt.log.write('Compiling...');
- cc.compile('/**@const*/var DEBUG=false;' + getCombinedSources(), options, function (err, stdout, stderr) {
+ var execFile = require('child_process').execFile;
+ var stream = require('stream');
+ var options = [
+ '--compilation_level', 'ADVANCED_OPTIMIZATIONS',
+ '--output_wrapper', '(function() {%output%})();'
+ ];
+ var source = new stream.Readable();
+ source.push('/**@const*/var DEBUG=false;' + getCombinedSources());
+ source.push(null);
+ var cc = execFile('closure-compiler', options, function (err, stdout, stderr) {
if (err) {
grunt.log.error(err);
done(false);
@@ -119,6 +122,8 @@
done(true);
}
});
+ grunt.log.write('Compiling...');
+ source.pipe(cc.stdin);
}
grunt.registerMultiTask('build', 'Build', function() {
|