1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.NsisScriptGenerator = void 0;
|
7 |
|
8 | class NsisScriptGenerator {
|
9 | constructor() {
|
10 | this.lines = [];
|
11 | }
|
12 |
|
13 | addIncludeDir(file) {
|
14 | this.lines.push(`!addincludedir "${file}"`);
|
15 | }
|
16 |
|
17 | addPluginDir(pluginArch, dir) {
|
18 | this.lines.push(`!addplugindir /${pluginArch} "${dir}"`);
|
19 | }
|
20 |
|
21 | include(file) {
|
22 | this.lines.push(`!include "${file}"`);
|
23 | }
|
24 |
|
25 | macro(name, lines) {
|
26 | this.lines.push(`!macro ${name}`, ` ${(Array.isArray(lines) ? lines : lines.lines).join("\n ")}`, `!macroend\n`);
|
27 | }
|
28 |
|
29 | file(outputName, file) {
|
30 | this.lines.push(`File${outputName == null ? "" : ` "/oname=${outputName}"`} "${file}"`);
|
31 | }
|
32 |
|
33 | insertMacro(name, parameters) {
|
34 | this.lines.push(`!insertmacro ${name} ${parameters}`);
|
35 | }
|
36 |
|
37 |
|
38 | flags(flags) {
|
39 | for (const flagName of flags) {
|
40 | const variableName = "is" + flagName[0].toUpperCase() + flagName.substring(1).replace(/[\-]+(\w|$)/g, (m, p1) => p1.toUpperCase());
|
41 | this.lines.push(`!macro _${variableName} _a _b _t _f
|
42 | $\{StdUtils.TestParameter} $R9 "${flagName}"
|
43 | StrCmp "$R9" "true" \`$\{_t}\` \`$\{_f}\`
|
44 | !macroend
|
45 | !define ${variableName} \`"" ${variableName} ""\`
|
46 | `);
|
47 | }
|
48 | }
|
49 |
|
50 | build() {
|
51 | return this.lines.join("\n") + "\n";
|
52 | }
|
53 |
|
54 | } exports.NsisScriptGenerator = NsisScriptGenerator;
|
55 |
|
\ | No newline at end of file |