forked from meltingice/CamanJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.js
52 lines (43 loc) · 1.29 KB
/
Makefile.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
var fs = require('fs'),
smoosh = require('smoosh'),
SRC_DIR = 'src',
PLUGIN_DIR = 'src/plugins/plugins';
/*
* Prepare our plugins
*/
// Make sure plugins submodule is initialized first
try {
fs.readdirSync(PLUGIN_DIR);
finish();
} catch (e) {
console.log("####################################");
console.log("It looks like the CamanJS-Plugins submodule hasn't");
console.log("been initialized yet. Let me fix that for you.");
console.log("####################################");
exec('git submodule init', function () {
exec('git submodule update --recursive', function () {
finish();
});
});
}
function finish() {
// then generate plugins.js file
try {
// Remove plugins.js if it exists
fs.statSync(SRC_DIR + "/plugins/plugins.js");
fs.unlinkSync(SRC_DIR + "/plugins/plugins.js");
} catch (e) { /* Do nothing */ }
var plugins = "";
fs.readdirSync(PLUGIN_DIR).forEach(function (plugin) {
plugins += fs.readFileSync(PLUGIN_DIR + '/' + plugin, 'UTF-8') + "\n";
});
// output plugins.js
fs.writeFileSync(SRC_DIR + "/plugins/plugins.js", plugins);
/*
* Time to smoosh!
*/
smoosh.config('./config.json');
smoosh.run().build().analyze();
// Remove the temporary plugins.js file
fs.unlinkSync(SRC_DIR + "/plugins/plugins.js");
}