create findShortcut

master
lub 7 years ago
parent 343864a126
commit 09b7f91e67

@ -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$/);