1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getLicenseFiles = exports.getNotLocalizedLicenseFile = exports.getLicenseAssets = void 0;
|
4 | const path = require("path");
|
5 | const langs_1 = require("./langs");
|
6 | function getLicenseAssets(fileNames, packager) {
|
7 | return fileNames
|
8 | .sort((a, b) => {
|
9 | const aW = a.includes("_en") ? 0 : 100;
|
10 | const bW = b.includes("_en") ? 0 : 100;
|
11 | return aW === bW ? a.localeCompare(b) : aW - bW;
|
12 | })
|
13 | .map(file => {
|
14 | let lang = /_([^.]+)\./.exec(file)[1];
|
15 | let langWithRegion;
|
16 | if (lang.includes("_")) {
|
17 | langWithRegion = lang;
|
18 | lang = langWithRegion.substring(0, lang.indexOf("_"));
|
19 | }
|
20 | else {
|
21 | lang = lang.toLowerCase();
|
22 | langWithRegion = (0, langs_1.toLangWithRegion)(lang);
|
23 | }
|
24 | return { file: path.join(packager.buildResourcesDir, file), lang, langWithRegion, langName: langs_1.langIdToName[lang] };
|
25 | });
|
26 | }
|
27 | exports.getLicenseAssets = getLicenseAssets;
|
28 | async function getNotLocalizedLicenseFile(custom, packager, supportedExtension = ["rtf", "txt", "html"]) {
|
29 | const possibleFiles = [];
|
30 | for (const name of ["license", "eula"]) {
|
31 | for (const ext of supportedExtension) {
|
32 | possibleFiles.push(`${name}.${ext}`);
|
33 | possibleFiles.push(`${name.toUpperCase()}.${ext}`);
|
34 | possibleFiles.push(`${name}.${ext.toUpperCase()}`);
|
35 | possibleFiles.push(`${name.toUpperCase()}.${ext.toUpperCase()}`);
|
36 | }
|
37 | }
|
38 | return await packager.getResource(custom, ...possibleFiles);
|
39 | }
|
40 | exports.getNotLocalizedLicenseFile = getNotLocalizedLicenseFile;
|
41 | async function getLicenseFiles(packager) {
|
42 | return getLicenseAssets((await packager.resourceList).filter(it => {
|
43 | const name = it.toLowerCase();
|
44 | return (name.startsWith("license_") || name.startsWith("eula_")) && (name.endsWith(".rtf") || name.endsWith(".txt") || name.endsWith(".html"));
|
45 | }), packager);
|
46 | }
|
47 | exports.getLicenseFiles = getLicenseFiles;
|
48 |
|
\ | No newline at end of file |