Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tshino committed Nov 30, 2021
1 parent d7f37d2 commit d351381
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions generator/gen_keymap_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,7 @@ function makeWrapper(keybinding) {
return wrapped;
}

async function makeKeymapWrapper(configPath) {
const dirname = path.dirname(configPath);
const id = path.basename(configPath, '.config.json');
const packageJsonPath = path.resolve(dirname, 'tmp/' + id + '.package.json');
const packageJson = await genWrapperUtil.readJSON(packageJsonPath);
console.log('generating keymap wrapper for', { id, displayName: packageJson['displayName'] });

const config = await genWrapperUtil.readJSON(configPath);
const exclusion = new Set(config['exclusion'] || []);
const awaitOptions = new Map(config['awaitOptions'] || []);

const baseKeybindings = packageJson['contributes']['keybindings'];

// resolve wildcards in awaitOptions
function resolveWildcardInAwaitOptions(awaitOptions, baseKeybindings) {
const wildcardCommands = Array.from(awaitOptions.keys()).filter(
command => command.endsWith('*')
);
Expand All @@ -60,6 +47,22 @@ async function makeKeymapWrapper(configPath) {
}
awaitOptions.delete(wildcard);
}
}

async function makeKeymapWrapper(configPath) {
const dirname = path.dirname(configPath);
const id = path.basename(configPath, '.config.json');
const packageJsonPath = path.resolve(dirname, 'tmp/' + id + '.package.json');
const packageJson = await genWrapperUtil.readJSON(packageJsonPath);
console.log('** generating keymap wrapper for', { id, displayName: packageJson['displayName'] });

const config = await genWrapperUtil.readJSON(configPath);
const exclusion = new Set(config['exclusion'] || []);
const awaitOptions = new Map(config['awaitOptions'] || []);

const baseKeybindings = packageJson['contributes']['keybindings'];

resolveWildcardInAwaitOptions(awaitOptions, baseKeybindings);

const wrappers = baseKeybindings.map(
keybinding => {
Expand Down

0 comments on commit d351381

Please sign in to comment.