UNPKG

3.03 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.getLicenseAssets = getLicenseAssets;
7exports.getLicenseFiles = exports.getNotLocalizedLicenseFile = void 0;
8
9function _bluebirdLst() {
10 const data = require("bluebird-lst");
11
12 _bluebirdLst = function () {
13 return data;
14 };
15
16 return data;
17}
18
19var path = _interopRequireWildcard(require("path"));
20
21function _langs() {
22 const data = require("builder-util/out/langs");
23
24 _langs = function () {
25 return data;
26 };
27
28 return data;
29}
30
31function _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; } }
32
33function getLicenseAssets(fileNames, packager) {
34 return fileNames.sort((a, b) => {
35 const aW = a.includes("_en") ? 0 : 100;
36 const bW = b.includes("_en") ? 0 : 100;
37 return aW === bW ? a.localeCompare(b) : aW - bW;
38 }).map(file => {
39 let lang = file.match(/_([^.]+)\./)[1];
40 let langWithRegion;
41
42 if (lang.includes("_")) {
43 langWithRegion = lang;
44 lang = langWithRegion.substring(0, lang.indexOf("_"));
45 } else {
46 lang = lang.toLowerCase();
47 langWithRegion = (0, _langs().toLangWithRegion)(lang);
48 }
49
50 return {
51 file: path.join(packager.buildResourcesDir, file),
52 lang,
53 langWithRegion,
54 langName: _langs().langIdToName[lang]
55 };
56 });
57}
58
59let getNotLocalizedLicenseFile = (() => {
60 var _ref = (0, _bluebirdLst().coroutine)(function* (custom, packager, supportedExtension = ["rtf", "txt", "html"]) {
61 const possibleFiles = [];
62
63 for (const name of ["license", "eula"]) {
64 for (const ext of supportedExtension) {
65 possibleFiles.push(`${name}.${ext}`);
66 possibleFiles.push(`${name.toUpperCase()}.${ext}`);
67 possibleFiles.push(`${name}.${ext.toUpperCase()}`);
68 possibleFiles.push(`${name.toUpperCase()}.${ext.toUpperCase()}`);
69 }
70 }
71
72 return yield packager.getResource(custom, ...possibleFiles);
73 });
74
75 return function getNotLocalizedLicenseFile(_x, _x2) {
76 return _ref.apply(this, arguments);
77 };
78})();
79
80exports.getNotLocalizedLicenseFile = getNotLocalizedLicenseFile;
81
82let getLicenseFiles = (() => {
83 var _ref2 = (0, _bluebirdLst().coroutine)(function* (packager) {
84 return getLicenseAssets((yield packager.resourceList).filter(it => {
85 const name = it.toLowerCase();
86 return (name.startsWith("license_") || name.startsWith("eula_")) && (name.endsWith(".rtf") || name.endsWith(".txt"));
87 }), packager);
88 });
89
90 return function getLicenseFiles(_x3) {
91 return _ref2.apply(this, arguments);
92 };
93})(); exports.getLicenseFiles = getLicenseFiles;
94//# sourceMappingURL=license.js.map
\No newline at end of file