Centralize OS-specific configuration and modifier mappings in a dedicated config/adapter module and document global declaration files. Motivation: key modifiers (Cmd/Meta/Alt/Option), global shortcuts, and shared types behave differently across platforms; putting the logic in one place avoids inconsistent handling, duplicate OS checks, and brittle startup code.
Rules and how to apply:
Code examples (patterns to follow):
Platform mapping helper (conceptual) const isMac = process.platform === “darwin”; export function mapLogicalModifier(mod: ‘Cmd’ | ‘Meta’ | ‘Option’) { if (mod === ‘Cmd’) return isMac ? ‘Meta’ : ‘Alt’; if (mod === ‘Option’) return isMac ? ‘Alt’ : ‘Alt’; return ‘Meta’; // fallback }
Use mapping in prettyPrintKeybind: function prettyPrintKeybind(keyDescription: string): string { const keyPress = parseKeyDescription(keyDescription); const mappedMods = { Cmd: mapLogicalModifier(‘Cmd’), Option: mapLogicalModifier(‘Option’), // respect explicit Meta/Alt in keyPress.mods if present }; // build display string using mappedMods and platform symbols }
OS-aware global shortcut registration: if (isMac) { reregisterGlobalShortcut(‘Cmd+F4’); } else if (process.platform === ‘linux’ || process.platform === ‘win32’) { reregisterGlobalShortcut(‘Alt+F4’); }
Practical checklist for PRs:
This ensures consistent cross-platform behavior, easier testing and maintenance, and a single place to update OS-specific settings.
Enter the URL of a public GitHub repository