Total Complexity | 10 |
Complexity/F | 10 |
Lines of Code | 62 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { files } from "../files" |
||
2 | import { |
||
3 | appenderSync, |
||
4 | arr2line, |
||
5 | createLineReader, |
||
6 | templateLine |
||
7 | } from "../utils" |
||
8 | |||
9 | export { |
||
10 | main, |
||
11 | // varsMap |
||
12 | } |
||
13 | |||
14 | if (!module.parent) |
||
15 | main() |
||
16 | |||
17 | async function main() { |
||
18 | const templateRoot = `${__dirname}/template/` |
||
19 | , outputRoot = `${__dirname}/output/` |
||
20 | |||
21 | for (const id_ in files) { |
||
22 | const { |
||
23 | path, |
||
24 | } = files[id_] |
||
25 | |||
26 | if (!path) |
||
27 | continue |
||
28 | |||
29 | const append = appenderSync(`${outputRoot}${path}`) |
||
30 | |||
31 | for await (const line of createLineReader(`${templateRoot}${path}`)) { |
||
32 | const templ = templateLine<"id"|"value"|"prefix"|"postfix">(line) |
||
33 | |||
34 | if (!templ) { |
||
35 | await append(line, "\n") |
||
36 | continue |
||
37 | } |
||
38 | |||
39 | const { |
||
40 | indentation, |
||
41 | id, |
||
42 | value, |
||
43 | prefix, |
||
44 | postfix |
||
45 | } = templ |
||
46 | , valueStr = value ? `=${value}` : "" |
||
47 | |||
48 | await append( |
||
49 | arr2line(indentation, prefix, `ENV_${id}${valueStr}`, postfix) |
||
50 | ) |
||
51 | |||
52 | for (const key in files) { |
||
53 | if (key === id) |
||
54 | continue |
||
55 | await append( |
||
56 | arr2line(indentation, prefix, `${id}_CATCH_${key}${value ? `=\${ENV_${key}}` : ""}`, postfix) |
||
57 | ) |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 |