add project import to commands.js

master
lub 7 years ago
parent dd7c20f417
commit 4251245218

@ -1,3 +1,5 @@
const fs = require('fs');
// Compute the edit distance between the two given strings // Compute the edit distance between the two given strings
function getEditDistance(sourceString, targetString) { function getEditDistance(sourceString, targetString) {
if (sourceString.length === 0) return targetString.length; if (sourceString.length === 0) return targetString.length;
@ -54,6 +56,17 @@ function fetchCommand(input, commands, threshhold){
module.exports.fetchCommand = fetchCommand; module.exports.fetchCommand = fetchCommand;
module.exports.getEditDistance = getEditDistance; 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 /* //Test code
const commands = {}; const commands = {};
commands['homeserver'] = {}; commands['homeserver'] = {};