diff --git a/commands.js b/commands.js index 4c8478d..0282216 100644 --- a/commands.js +++ b/commands.js @@ -58,6 +58,26 @@ function fetchCommand(input, commands, threshhold){ commands.fetchCommand = fetchCommand; commands.getEditDistance = getEditDistance; +const findShortcut = (shortcut, objects) => { + const regex = new RegExp('^' + shortcut + '.*'); + let expansionCount = 0; + let expansion = false; + + for(let key in objects) { + if(regex.test(key)) { + expansionCount++; + + if(expansionCount > 1) { + return false; + }; + + expansion = key; + }; + }; + + return expansion; +}; + commands.projects = {} fs.readdirSync('./projects').forEach((file) => { let project = file.match(/^([a-z]*)\.js$/);