Skip to content

Commit

Permalink
Add warning for unknown command in config #11
Browse files Browse the repository at this point in the history
  • Loading branch information
tshino committed Dec 3, 2021
1 parent d1f58a1 commit ddfa2bc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions generator/gen_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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)) {
Expand All @@ -49,6 +57,8 @@ async function main() {
checkAwaitOptions(awaitOptions);

const baseKeybindings = await genWrapperUtil.loadBaseKeybindings(config['baseKeybindings'] || []);
const commands = new Set(baseKeybindings.flatMap(item => item.keybindings).map(keybinding => keybinding.command));
checkExclusion(exclusion, commands);

// combine the three sets of default keybindings of VS Code for Windows, Linux, and macOS.
const combined = genWrapperUtil.combineBaseKeybingings(baseKeybindings);
Expand Down

0 comments on commit ddfa2bc

Please sign in to comment.