diff --git a/commands.js b/commands.js index d5d5b16..943eb1a 100644 --- a/commands.js +++ b/commands.js @@ -1,3 +1,5 @@ +const fs = require('fs'); + // Compute the edit distance between the two given strings function getEditDistance(sourceString, targetString) { if (sourceString.length === 0) return targetString.length; @@ -54,6 +56,17 @@ function fetchCommand(input, commands, threshhold){ module.exports.fetchCommand = fetchCommand; module.exports.getEditDistance = getEditDistance; +fs.readdirSync('./projects').forEach((file) => { + let project = file.match(/^([a-z]*)\.js$/); + if(!project) { + //skip current forEach pass + return; + } + project = project[1]; + + module.exports[project] = require('./projects/' + file); +}); + /* //Test code const commands = {}; commands['homeserver'] = {};