Add Java options for faster Closure Compiler minification to minify.js.

Former-commit-id: b493d461e78d0df80c80805a570220fdff93d487
This commit is contained in:
John-David Dalton
2013-05-19 11:45:24 -07:00
parent 06daad87ca
commit 87af68c092

View File

@@ -3,8 +3,8 @@
'use strict';
/** Load Node.js modules */
var https = require('https'),
spawn = require('child_process').spawn,
var cp = require('child_process'),
https = require('https'),
zlib = require('zlib');
/** Load other modules */
@@ -59,6 +59,17 @@
};
}());
/**
* Java command-line options used for faster minification.
* See https://code.google.com/p/closure-compiler/wiki/FAQ#What_are_the_recommended_Java_VM_command-line_options?.
*/
var javaOptions = [];
cp.exec('java -version -client -d32', function(error) {
if (!error && process.platform != 'win32') {
javaOptions.push('-client', '-d32');
}
});
/** The Closure Compiler optimization modes */
var optimizationModes = {
'simple': 'SIMPLE_OPTIMIZATIONS',
@@ -375,8 +386,7 @@
if (isMapped) {
options.push('--create_source_map=' + mapPath, '--source_map_format=V3');
}
var compiler = spawn('java', ['-jar', closurePath].concat(options));
var compiler = cp.spawn('java', javaOptions.concat('-jar', closurePath, options));
if (!this.isSilent) {
console.log('Compressing ' + path.basename(outputPath, '.js') + ' using the Closure Compiler (' + mode + ')...');
}