-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathengine_config.js
60 lines (48 loc) · 1.05 KB
/
engine_config.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
var fs = require("fs");
// cc-yaml currently ends up passing bools as stringy equivalents
function _coerceBool(val) {
if (typeof(val) === "string") {
return val === "true";
} else {
return !!val;
}
}
class UserEngineConfig {
constructor(json) {
this.json = json;
}
get configPath() {
return this.json.config;
}
get extensions() {
return this.json.extensions;
}
get debug() {
return _coerceBool(this.json.debug);
}
get ignorePath() {
return this.json.ignore_path;
}
get ignoreWarnings() {
return _coerceBool(this.json.ignore_warnings);
}
get sanitizeBatch() {
if (this.json.hasOwnProperty("sanitize_batch")) {
return _coerceBool(this.json.sanitize_batch);
} else {
return true;
}
}
}
class EngineConfig {
constructor(path) {
this.engineJSON = JSON.parse(fs.readFileSync(path));
}
get includePaths() {
return this.engineJSON.include_paths;
}
get userConfig() {
return new UserEngineConfig(this.engineJSON.config || {});
}
}
module.exports = EngineConfig;