-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
95 lines (83 loc) · 2.36 KB
/
build.js
File metadata and controls
95 lines (83 loc) · 2.36 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
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
89
90
91
92
93
94
95
(function(){
var gear = require('gear');
var gear_lib = require('gear-lib');
var FILES = ["InternalHeader.js", "Constants.js", "ConfigManager.js", "Exception.js", "Util.js", "Spec.js", "Importer.js", "../lib/LazyLoad/lazyload.js", "ClassMetadata.js", "ClassMaker.js",
"TraitMetadata.js", "TraitMaker.js", "ObjectMaker.js", "PublicAPI.js", "InternalFooter.js"];
var processFiles = function(files){
var mappedFiles = files.map(function(value){
return './src/' + value;
});
return mappedFiles;
};
function getAllFiles(){
return processFiles(FILES);
}
function buildEnvBrowser(debug){
var build = new gear.Queue({registry: new gear.Registry({module: 'gear-lib'})})
.log("=== Building FlancheJs ===")
.log("#Reading files")
.read(getAllFiles())
.log("#Concatenating files")
.concat();
if(!debug){
build = build.log("#Minifying files")
.jsminify({
config: {
mangle: true
}
})
.log("#Writing to ./dist/FlancheJs.min.js")
.write("./dist/FlancheJs.min.js");
}
else{
build = build.log("#Writing to ./dist/FlancheJs.debug.js")
.write("./dist/FlancheJs.debug.js")
}
build.run(function(err, results){
if(err){
console.log(err);
return;
}
console.log("#Build finished successfully!");
});
}
function buildEnvNode(){
var build = new gear.Queue({registry: new gear.Registry({module: 'gear-lib'})})
.log("=== Building FlancheJs ===")
.log("#Reading files")
.read(getAllFiles())
.log("#Concatenating files")
.concat()
.log("#Minifying files")
.log("#Writing to ./dist/FlancheJs.node.js")
.write("./dist/FlancheJs.node.js")
.run(function(err, results){
if(err){
console.log(err);
return;
}
console.log("#Build finished successfully!");
});
}
function parseCommands(){
var debug = false, env = "browser";
process.argv.forEach(function(value){
if(value === "--debug"){
debug = true;
}
else if(value === "--browser"){
env = "browser";
}
else if(value === "--nodejs"){
env = "nodejs";
}
});
if(env === "browser"){
buildEnvBrowser(debug);
}
else{
buildEnvNode();
}
}
parseCommands();
})();