add project import to commands.js

develop
lub 7 years ago
parent fc9c29d74e
commit c8d449ed8f

@ -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'] = {};