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) {
|
||||
return cb(["otherpart:somehook was here"]);
|
||||
}
|
||||
|
@ -7,9 +10,6 @@ exports.morehook = 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) {
|
||||
res.send("<em>Abra cadabra</em>");
|
||||
});
|
||||
|
|
|
@ -21,16 +21,6 @@ exports.ensure = function (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 () {
|
||||
return Object.keys(exports.plugins).join(", ");
|
||||
}
|
||||
|
@ -49,13 +39,13 @@ exports.formatHooks = function () {
|
|||
return res.join("\n");
|
||||
}
|
||||
|
||||
exports.getPlugins = function (cb) {
|
||||
exports.update = function (cb) {
|
||||
exports.getPackages(function (er, packages) {
|
||||
packages.__builtin__ = {
|
||||
"path": path.resolve(npm.dir, "../..")
|
||||
};
|
||||
|
||||
var parts = {};
|
||||
var parts = [];
|
||||
var plugins = {};
|
||||
// Load plugin metadata pluginomatic.json
|
||||
async.forEach(
|
||||
|
@ -64,10 +54,11 @@ exports.getPlugins = function (cb) {
|
|||
exports.loadPlugin(packages, plugin_name, plugins, parts, cb);
|
||||
},
|
||||
function (err) {
|
||||
parts = exports.sortParts(parts);
|
||||
var hooks = exports.extractHooks(parts);
|
||||
// console.log(util.inspect(plugins, undefined, null));
|
||||
cb(err, plugins, parts, hooks);
|
||||
exports.plugins = plugins;
|
||||
exports.parts = exports.sortParts(parts);
|
||||
exports.hooks = exports.extractHooks(exports.parts);
|
||||
exports.loaded = true;
|
||||
cb(err);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -99,7 +90,7 @@ exports.extractHooks = function (parts) {
|
|||
parts.forEach(function (part) {
|
||||
Object.keys(part.hooks || {}).forEach(function (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]);
|
||||
if (hook_fn) {
|
||||
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