-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.js
55 lines (49 loc) · 1.44 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
const fs = require("fs");
const yaml = require("js-yaml");
let compileOption = process.argv.slice(2);
let filesToCompile = compileOption[0] || "all";
//compile p5r data to json
function compileP5RData() {
let p5rData = JSON.parse(JSON.stringify(yaml.load(fs.readFileSync('./data/p5r.yml', 'utf8')), null, 2));
try {
fs.writeFileSync('./compile/p5r.json', JSON.stringify(p5rData));
} catch (error) {
console.error(error);
}
}
//compile p4g data to json
function compileP4GData() {
let p4gData = JSON.parse(JSON.stringify(yaml.load(fs.readFileSync('./data/p4g.yml', 'utf8')), null, 2));
try {
fs.writeFileSync('./compile/p4g.json', JSON.stringify(p4gData));
} catch (error) {
console.error(error);
}
}
//compile p3re data to json
function compileP3REData() {
let p3reData = JSON.parse(JSON.stringify(yaml.load(fs.readFileSync('./data/p3re.yml', 'utf8')), null, 2));
try {
fs.writeFileSync('./compile/p3re.json', JSON.stringify(p3reData));
} catch (error) {
console.error(error);
}
}
switch (filesToCompile) {
case "all":
compileP3REData();
compileP4GData();
compileP5RData();
break;
case "p5r":
compileP5RData();
break;
case "p4g":
compileP4GData();
break;
case "p3re":
compileP3REData();
break;
default:
break;
}