-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsettings.js
77 lines (64 loc) · 2.61 KB
/
settings.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
var fs = require("fs");
var utils = require("./utils");
var config_snippet_path = utils.getBaseOrCustomPath("config/config.xml.snippet");
var loader_snippet_path = utils.getBaseOrCustomPath("config/loader.html.snippet");
var loader_styling_snippet_path = utils.getBaseOrCustomPath("config/loader.css.snippet");
var custom_styling_snippet_path = utils.getBaseOrCustomPath("config/custom.css.snippet");
function compile_settings(env) {
var settings = Object.assign(
{
options: {
environment: "prod",
},
},
utils.loadConfiguration("config/parameters.json"),
utils.loadConfiguration("config/resources.json")
);
var environmentAliases = {
p: "production",
prod: "production",
a: "acceptance",
accp: "acceptance",
t: "test",
s: "sandbox",
d: "development",
dev: "development",
};
// Process the command line parameters.
if (env) {
if (env["target"]) {
Object.assign(settings.options, { environment: env["target"] });
}
if (env["arch"]) {
Object.assign(settings.options, { architecture: env["arch"] });
}
// Kept for backwards compatibility; Provides a shortcut for the arch option
["x86", "arm", "x86_64", "arm64"].forEach(function (architecture) {
if (env[architecture]) {
Object.assign(settings.options, { architecture: architecture });
}
});
Object.assign(settings.options, { debug: env["debug"] && env["debug"] !== "false" });
}
// Propagate the environment settings
var environments = utils.loadConfiguration("config/environments.json");
var target = settings.options.environment;
if (environmentAliases[target]) {
target = environmentAliases[target];
Object.assign(settings.options, { environment: target });
}
if (environments[settings.options.environment]) {
Object.assign(settings, environments[settings.options.environment]);
}
if (typeof settings.options.debug === "undefined") {
settings.options.debug = settings.options.environment !== "production";
}
Object.assign(settings, {
customConfiguration: fs.readFileSync(config_snippet_path, { encoding: "utf8" }),
loaderHtml: fs.readFileSync(loader_snippet_path, { encoding: "utf8" }),
loaderCss: fs.readFileSync(loader_styling_snippet_path, { encoding: "utf8" }),
customCss: fs.readFileSync(custom_styling_snippet_path, { encoding: "utf8" }),
});
return settings;
}
module.exports = compile_settings;