1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.DesktopShortcutCreationPolicy = exports.getEffectiveOptions = void 0;
|
4 | const builder_util_1 = require("builder-util");
|
5 | const filename_1 = require("../util/filename");
|
6 | function getEffectiveOptions(options, packager) {
|
7 | const appInfo = packager.appInfo;
|
8 | let menuCategory = null;
|
9 | if (options.menuCategory != null && options.menuCategory !== false) {
|
10 | if (options.menuCategory === true) {
|
11 | const companyName = packager.appInfo.companyName;
|
12 | if (companyName == null) {
|
13 | throw new builder_util_1.InvalidConfigurationError(`Please specify "author" in the application package.json — it is required because "menuCategory" is set to true.`);
|
14 | }
|
15 | menuCategory = filename_1.sanitizeFileName(companyName);
|
16 | }
|
17 | else {
|
18 | menuCategory = options.menuCategory
|
19 | .split(/[/\\]/)
|
20 | .map(it => filename_1.sanitizeFileName(it))
|
21 | .join("\\");
|
22 | }
|
23 | }
|
24 | return {
|
25 | isPerMachine: options.perMachine === true,
|
26 | isAssisted: options.oneClick === false,
|
27 | shortcutName: builder_util_1.isEmptyOrSpaces(options.shortcutName) ? appInfo.sanitizedProductName : packager.expandMacro(options.shortcutName),
|
28 | isCreateDesktopShortcut: convertToDesktopShortcutCreationPolicy(options.createDesktopShortcut),
|
29 | isCreateStartMenuShortcut: options.createStartMenuShortcut !== false,
|
30 | menuCategory,
|
31 | };
|
32 | }
|
33 | exports.getEffectiveOptions = getEffectiveOptions;
|
34 | function convertToDesktopShortcutCreationPolicy(value) {
|
35 | if (value === false) {
|
36 | return DesktopShortcutCreationPolicy.NEVER;
|
37 | }
|
38 | else if (value === "always") {
|
39 | return DesktopShortcutCreationPolicy.ALWAYS;
|
40 | }
|
41 | else {
|
42 | return DesktopShortcutCreationPolicy.FRESH_INSTALL;
|
43 | }
|
44 | }
|
45 | var DesktopShortcutCreationPolicy;
|
46 | (function (DesktopShortcutCreationPolicy) {
|
47 | DesktopShortcutCreationPolicy[DesktopShortcutCreationPolicy["FRESH_INSTALL"] = 0] = "FRESH_INSTALL";
|
48 | DesktopShortcutCreationPolicy[DesktopShortcutCreationPolicy["ALWAYS"] = 1] = "ALWAYS";
|
49 | DesktopShortcutCreationPolicy[DesktopShortcutCreationPolicy["NEVER"] = 2] = "NEVER";
|
50 | })(DesktopShortcutCreationPolicy = exports.DesktopShortcutCreationPolicy || (exports.DesktopShortcutCreationPolicy = {}));
|
51 |
|
\ | No newline at end of file |