plugins.plugins is now defined while loading hook modules from plugins
This commit is contained in:
parent
2a58a62dcc
commit
1955bdec9a
|
@ -1,3 +1,6 @@
|
||||||
|
test = ep_client_require("/plugins/pluginomatic_fintest/test.js");
|
||||||
|
console.log("FOOO:", test.foo);
|
||||||
|
|
||||||
exports.somehook = function (hook_name, args, cb) {
|
exports.somehook = function (hook_name, args, cb) {
|
||||||
return cb(["otherpart:somehook was here"]);
|
return cb(["otherpart:somehook was here"]);
|
||||||
}
|
}
|
||||||
|
@ -7,9 +10,6 @@ exports.morehook = function (hook_name, args, cb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.expressServer = function (hook_name, args, cb) {
|
exports.expressServer = function (hook_name, args, cb) {
|
||||||
test = ep_client_require("/plugins/pluginomatic_fintest/test.js");
|
|
||||||
console.log("FOOO:", test.foo);
|
|
||||||
|
|
||||||
args.app.get('/otherpart', function(req, res) {
|
args.app.get('/otherpart', function(req, res) {
|
||||||
res.send("<em>Abra cadabra</em>");
|
res.send("<em>Abra cadabra</em>");
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,16 +21,6 @@ exports.ensure = function (cb) {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.update = function (cb) {
|
|
||||||
exports.getPlugins(function (er, plugins, parts, hooks) {
|
|
||||||
exports.plugins = plugins;
|
|
||||||
exports.parts = parts;
|
|
||||||
exports.hooks = hooks;
|
|
||||||
exports.loaded = true;
|
|
||||||
cb(er);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.formatPlugins = function () {
|
exports.formatPlugins = function () {
|
||||||
return Object.keys(exports.plugins).join(", ");
|
return Object.keys(exports.plugins).join(", ");
|
||||||
}
|
}
|
||||||
|
@ -49,13 +39,13 @@ exports.formatHooks = function () {
|
||||||
return res.join("\n");
|
return res.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getPlugins = function (cb) {
|
exports.update = function (cb) {
|
||||||
exports.getPackages(function (er, packages) {
|
exports.getPackages(function (er, packages) {
|
||||||
packages.__builtin__ = {
|
packages.__builtin__ = {
|
||||||
"path": path.resolve(npm.dir, "../..")
|
"path": path.resolve(npm.dir, "../..")
|
||||||
};
|
};
|
||||||
|
|
||||||
var parts = {};
|
var parts = [];
|
||||||
var plugins = {};
|
var plugins = {};
|
||||||
// Load plugin metadata pluginomatic.json
|
// Load plugin metadata pluginomatic.json
|
||||||
async.forEach(
|
async.forEach(
|
||||||
|
@ -64,10 +54,11 @@ exports.getPlugins = function (cb) {
|
||||||
exports.loadPlugin(packages, plugin_name, plugins, parts, cb);
|
exports.loadPlugin(packages, plugin_name, plugins, parts, cb);
|
||||||
},
|
},
|
||||||
function (err) {
|
function (err) {
|
||||||
parts = exports.sortParts(parts);
|
exports.plugins = plugins;
|
||||||
var hooks = exports.extractHooks(parts);
|
exports.parts = exports.sortParts(parts);
|
||||||
// console.log(util.inspect(plugins, undefined, null));
|
exports.hooks = exports.extractHooks(exports.parts);
|
||||||
cb(err, plugins, parts, hooks);
|
exports.loaded = true;
|
||||||
|
cb(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -99,7 +90,7 @@ exports.extractHooks = function (parts) {
|
||||||
parts.forEach(function (part) {
|
parts.forEach(function (part) {
|
||||||
Object.keys(part.hooks || {}).forEach(function (hook_name) {
|
Object.keys(part.hooks || {}).forEach(function (hook_name) {
|
||||||
if (hooks[hook_name] === undefined) hooks[hook_name] = [];
|
if (hooks[hook_name] === undefined) hooks[hook_name] = [];
|
||||||
var hook_fn_name = part.hooks[hook_name];
|
var hook_fn_name = part.hooks[hook_name];
|
||||||
var hook_fn = exports.loadFn(part.hooks[hook_name]);
|
var hook_fn = exports.loadFn(part.hooks[hook_name]);
|
||||||
if (hook_fn) {
|
if (hook_fn) {
|
||||||
hooks[hook_name].push({"hook_name": hook_name, "hook_fn": hook_fn, "hook_fn_name": hook_fn_name, "part": part});
|
hooks[hook_name].push({"hook_name": hook_name, "hook_fn": hook_fn, "hook_fn_name": hook_fn_name, "part": part});
|
||||||
|
|
Loading…
Reference in New Issue