-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
36 lines (31 loc) · 943 Bytes
/
util.js
File metadata and controls
36 lines (31 loc) · 943 Bytes
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
export function render(item) {
if (item === null || item === undefined) return null;
if (typeof item === "object") {
if (Array.isArray(item)) {
return item.map(i => render(i));
} else {
for (let [key, value] of Object.entries(item)) {
item[key] = render(value);
}
return item;
}
} else {
if (typeof item === "string" && item.match(/^\%d/)) {
return process.env[item.substr(3)]
? parseInt(process.env[item.substr(3)], 10)
: undefined;
}
if (typeof item === "string" && item.match(/^\%f/)) {
return process.env[item.substr(3)]
? parseFloat(process.env[item.substr(3)])
: undefined;
}
if (typeof item === "string" && item.match(/^\%s/)) {
return process.env[item.substr(3)];
}
if (typeof item === "string" && item.match(/^\%b/)) {
return process.env[item.substr(3)] === "true";
}
return item;
}
}