forked from nextapps-de/flexsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.js
88 lines (60 loc) · 2.33 KB
/
compile.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
var child_process = require('child_process');
console.log("Start build .....");
var parameter = (function(opt){
var parameter = '';
for(var index in opt){
if(opt.hasOwnProperty(index)){
parameter += ' --' + index + '=' + opt[index];
}
}
console.log(parameter);
return parameter;
})({
compilation_level: "ADVANCED_OPTIMIZATIONS",
use_types_for_optimization: true,
new_type_inf: true,
jscomp_warning: "newCheckTypes",
generate_exports: true,
export_local_property_definitions: true,
language_in: "ECMASCRIPT5_STRICT",
language_out: "ECMASCRIPT5_STRICT",
process_closure_primitives: true,
summary_detail_level: 3,
warning_level: "VERBOSE",
emit_use_strict: true,
output_manifest: "log/manifest.log",
output_module_dependencies: "log/module_dependencies.log",
property_renaming_report: "log/renaming_report.log"
});
var options = (function(argv){
var arr = {};
var count = 0;
argv.forEach(function(val, index) {
if(++count > 2){
index = val.split('=');
val = index[1];
index = index[0];
arr[index] = val;
if(count > 3) console.log(index + ': ' + val);
}
});
console.log('RELEASE: ' + (arr['RELEASE'] || 'custom'));
return arr;
})(process.argv);
exec("java -jar node_modules/google-closure-compiler/compiler.jar" + parameter + " --define='SUPPORT_DEBUG=" + (options['SUPPORT_DEBUG'] || 'false') + "' --define='SUPPORT_WORKER=" + (options['SUPPORT_WORKER'] || 'false') + "' --define='SUPPORT_BUILTINS=" + (options['SUPPORT_BUILTINS'] || 'false') + "' --define='SUPPORT_CACHE=" + (options['SUPPORT_CACHE'] || 'false') + "' --define='SUPPORT_ASYNC=" + (options['SUPPORT_ASYNC'] || 'false') + "' --js='flexsearch.js' --js_output_file='flexsearch." + (options['RELEASE'] || 'custom') + ".js' && exit 0", function(){
console.log("Build Complete: flexsearch." + (options['RELEASE'] || 'custom') + ".js");
});
function exec(prompt, callback){
var child = child_process.exec(prompt, function(err, stdout, stderr){
if(err){
console.log(err);
}
else{
if(callback){
callback();
}
}
});
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
}