Move header.json to package.json for node projects
This commit is contained in:
parent
a4bf401f32
commit
95781d7b0d
@ -1,8 +0,0 @@
|
||||
{
|
||||
"name": "Hello world",
|
||||
"description": "Hello world, example module for embeded messages",
|
||||
"prefix": "!hello",
|
||||
"flavor": "node",
|
||||
"entrypoint": "index.js",
|
||||
"version": "0.0.1"
|
||||
}
|
12
modules/hello_world/package.json
Normal file
12
modules/hello_world/package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "hello-world",
|
||||
"version": "0.0.1",
|
||||
"description": "Hello world, example module for embeded messages",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Tanguy Herbron",
|
||||
"license": "MIT",
|
||||
"prefix": "!hello"
|
||||
}
|
@ -16,16 +16,27 @@ class ModuleManager {
|
||||
scanModules() {
|
||||
console.log("Scanning for modules");
|
||||
fs.readdirSync(process.env.MODULES_DIR).forEach(file => {
|
||||
let rawData = fs.readFileSync(process.env.MODULES_DIR + "/" + file + "/header.json");
|
||||
let path = process.env.MODULES_DIR + "/" + file + "/package.json";
|
||||
|
||||
if(fs.existsSync(path)) {
|
||||
this.loadNodeModule(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
loadNodeModule(path) {
|
||||
let rawData = fs.readFileSync(path);
|
||||
let header = JSON.parse(rawData);
|
||||
|
||||
let modulePath = path.substring(0, path.lastIndexOf('/'));
|
||||
let entrypoint = modulePath + "/" + header.main;
|
||||
|
||||
this.moduleList[header.prefix] = new Module(header.name,
|
||||
header.description,
|
||||
header.prefix,
|
||||
header.flavor,
|
||||
process.env.MODULES_DIR + "/" + file + "/" + header.entrypoint,
|
||||
"node",
|
||||
entrypoint,
|
||||
header.version);
|
||||
});
|
||||
}
|
||||
|
||||
execute(prefix, message) {
|
||||
|
Loading…
Reference in New Issue
Block a user