From d1f58a1fd56a5478e9b9708d52a477e59dd95628 Mon Sep 17 00:00:00 2001 From: tshino Date: Thu, 2 Dec 2021 23:02:14 +0900 Subject: [PATCH] Add warning for unknown command in config #11 --- generator/gen_keymap_wrapper.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/generator/gen_keymap_wrapper.js b/generator/gen_keymap_wrapper.js index 52c9973a..9615fba4 100644 --- a/generator/gen_keymap_wrapper.js +++ b/generator/gen_keymap_wrapper.js @@ -32,6 +32,14 @@ function makeWrapper(keybinding) { return wrapped; } +function checkExclusion(exclusion, commands) { + for (const command of exclusion) { + if (!commands.has(command)) { + console.warn('Warning: No matching command:', command); + } + } +} + function checkAwaitOptions(awaitOptions) { for (const awaitOption of awaitOptions.values()) { if (!genWrapperUtil.isValidAwaitOption(awaitOption)) { @@ -71,11 +79,13 @@ async function makeKeymapWrapper(configPath) { console.log('** generating keymap wrapper for', { id, displayName: packageJson['displayName'] }); const config = await genWrapperUtil.readJSON(configPath); - const exclusion = new Set(config['exclusion'] || []); const baseKeybindings = packageJson['contributes']['keybindings']; const commands = new Set(baseKeybindings.map(keybinding => keybinding.command)); + const exclusion = new Set(config['exclusion'] || []); + checkExclusion(exclusion, commands); + const rawAwaitOptions = new Map(config['awaitOptions'] || []); const awaitOptions = resolveWildcardInAwaitOptions(rawAwaitOptions, commands); checkAwaitOptions(awaitOptions);