diff --git a/builder/index.js b/builder/index.js index 6d66183..94a446d 100644 --- a/builder/index.js +++ b/builder/index.js @@ -33,7 +33,7 @@ const fs = require("fs"); const os = require("os"); const path = require("path"); const { MIME_TYPES, ALL_FILES } = require("./mime"); -const { installerScript, columnsOf, MAX_COLUMNS, ROWS } = require("./installer"); +const { installerScript, columnsOf, MAX_COLUMNS, ROWS, MAX_LABEL } = require("./installer"); /** What an app's config extends: the kit's base config, by the package's name. */ const KIT_BASE = "@diamonddigitaldev/electron-kit/builder/base.json"; @@ -89,6 +89,9 @@ function checkContextMenu(contextMenu) { if (typeof contextMenu.label !== "string" || contextMenu.label.trim() === "" || /["\r\n]/.test(contextMenu.label)) { throw new Error("config(): contextMenu.label must be the entry's text, such as \"Convert with App\", on one line, without quotes."); } + if (contextMenu.label.length > MAX_LABEL) { + throw new Error(`config(): contextMenu.label is ${contextMenu.label.length} characters; the installer's line holds ${MAX_LABEL}. Shorten it, such as "Convert with App".`); + } if (contextMenu.folders !== undefined && typeof contextMenu.folders !== "boolean") throw new Error("config(): contextMenu.folders must be true or false."); if (contextMenu.args !== undefined && (!Array.isArray(contextMenu.args) || !contextMenu.args.every((arg) => typeof arg === "string" && /^--[a-z0-9][a-z0-9-]*(=[A-Za-z0-9._-]+)?$/.test(arg)))) { throw new Error("config(): contextMenu.args must be switches, such as [\"--upload\"]."); diff --git a/builder/installer.js b/builder/installer.js index 0c454cc..71784b2 100644 --- a/builder/installer.js +++ b/builder/installer.js @@ -32,6 +32,13 @@ const MAX_COLUMNS = 4; const ROWS = 8; +/** + * The longest right-click label the page's line holds: 'Add "