UNPKG

3.2 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.computeLicensePage = void 0;
7
8function _bluebirdLst() {
9 const data = require("bluebird-lst");
10
11 _bluebirdLst = function () {
12 return data;
13 };
14
15 return data;
16}
17
18function _langs() {
19 const data = require("builder-util/out/langs");
20
21 _langs = function () {
22 return data;
23 };
24
25 return data;
26}
27
28function _license() {
29 const data = require("../../util/license");
30
31 _license = function () {
32 return data;
33 };
34
35 return data;
36}
37
38var path = _interopRequireWildcard(require("path"));
39
40function _nsisUtil() {
41 const data = require("./nsisUtil");
42
43 _nsisUtil = function () {
44 return data;
45 };
46
47 return data;
48}
49
50function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
51
52let computeLicensePage = (() => {
53 var _ref = (0, _bluebirdLst().coroutine)(function* (packager, options, scriptGenerator, languages) {
54 const license = yield (0, _license().getNotLocalizedLicenseFile)(options.license, packager);
55
56 if (license != null) {
57 let licensePage;
58
59 if (license.endsWith(".html")) {
60 licensePage = ["!define MUI_PAGE_CUSTOMFUNCTION_SHOW LicenseShow", "Function LicenseShow", " FindWindow $R0 `#32770` `` $HWNDPARENT", " GetDlgItem $R0 $R0 1000", "EmbedHTML::Load /replace $R0 file://$PLUGINSDIR\\license.html", "FunctionEnd", `!insertmacro MUI_PAGE_LICENSE "${path.join(_nsisUtil().nsisTemplatesDir, "empty-license.txt")}"`];
61 } else {
62 licensePage = [`!insertmacro MUI_PAGE_LICENSE "${license}"`];
63 }
64
65 scriptGenerator.macro("licensePage", licensePage);
66
67 if (license.endsWith(".html")) {
68 scriptGenerator.macro("addLicenseFiles", [`File /oname=$PLUGINSDIR\\license.html "${license}"`]);
69 }
70
71 return;
72 }
73
74 const licenseFiles = yield (0, _license().getLicenseFiles)(packager);
75
76 if (licenseFiles.length === 0) {
77 return;
78 }
79
80 const licensePage = [];
81 const unspecifiedLangs = new Set(languages);
82 let defaultFile = null;
83
84 for (const item of licenseFiles) {
85 unspecifiedLangs.delete(item.langWithRegion);
86
87 if (defaultFile == null) {
88 defaultFile = item.file;
89 }
90
91 licensePage.push(`LicenseLangString MUILicense ${_langs().lcid[item.langWithRegion] || item.lang} "${item.file}"`);
92 }
93
94 for (const l of unspecifiedLangs) {
95 licensePage.push(`LicenseLangString MUILicense ${_langs().lcid[l]} "${defaultFile}"`);
96 }
97
98 licensePage.push('!insertmacro MUI_PAGE_LICENSE "$(MUILicense)"');
99 scriptGenerator.macro("licensePage", licensePage);
100 });
101
102 return function computeLicensePage(_x, _x2, _x3, _x4) {
103 return _ref.apply(this, arguments);
104 };
105})(); exports.computeLicensePage = computeLicensePage;
106//# sourceMappingURL=nsisLicense.js.map
\No newline at end of file