mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
Added init hook to install plugin database default content and the like
This commit is contained in:
parent
4325f0b907
commit
8cd1298a16
1 changed files with 24 additions and 1 deletions
|
@ -93,6 +93,28 @@ if (exports.isClient) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
exports.callInit = function (cb) {
|
||||||
|
var hooks = require("./hooks");
|
||||||
|
async.map(
|
||||||
|
Object.keys(exports.plugins),
|
||||||
|
function (plugin_name, cb) {
|
||||||
|
var plugin = exports.plugins[plugin_name];
|
||||||
|
fs.stat(path.normalize(path.join(plugin.package.path, ".ep_initialized")), function (err, stats) {
|
||||||
|
if (err) {
|
||||||
|
async.waterfall([
|
||||||
|
function (cb) { fs.writeFile(path.normalize(path.join(plugin.package.path, ".ep_initialized")), 'done', cb); },
|
||||||
|
function (cb) { hooks.aCallAll("init_" + plugin_name, {}, cb); },
|
||||||
|
cb,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function () { cb(); }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
exports.update = function (cb) {
|
exports.update = function (cb) {
|
||||||
exports.getPackages(function (er, packages) {
|
exports.getPackages(function (er, packages) {
|
||||||
var parts = [];
|
var parts = [];
|
||||||
|
@ -104,11 +126,12 @@ exports.update = function (cb) {
|
||||||
exports.loadPlugin(packages, plugin_name, plugins, parts, cb);
|
exports.loadPlugin(packages, plugin_name, plugins, parts, cb);
|
||||||
},
|
},
|
||||||
function (err) {
|
function (err) {
|
||||||
|
if (err) cb(err);
|
||||||
exports.plugins = plugins;
|
exports.plugins = plugins;
|
||||||
exports.parts = exports.sortParts(parts);
|
exports.parts = exports.sortParts(parts);
|
||||||
exports.hooks = exports.extractHooks(exports.parts, "hooks");
|
exports.hooks = exports.extractHooks(exports.parts, "hooks");
|
||||||
exports.loaded = true;
|
exports.loaded = true;
|
||||||
cb(err);
|
exports.callInit(cb);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue