Make sure npm is initialized before requiring things (fix #1092)

This commit is contained in:
Marcel Klehr 2012-10-28 18:02:49 +01:00
parent d5ace6c163
commit e447a6fade
1 changed files with 31 additions and 13 deletions

View File

@ -21,31 +21,49 @@
* limitations under the License. * limitations under the License.
*/ */
var log4js = require('log4js')
, async = require('async')
;
// set up logger // set up logger
var log4js = require('log4js');
log4js.replaceConsole(); log4js.replaceConsole();
var settings = require('./utils/Settings'); var settings
, db
//set loglevel , plugins
log4js.setGlobalLogLevel(settings.loglevel); , hooks;
var db = require('./db/DB');
var async = require('async');
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
var npm = require("npm/lib/npm.js"); var npm = require("npm/lib/npm.js");
hooks.plugins = plugins;
async.waterfall([ async.waterfall([
// load npm
function(callback) {
npm.load({}, function(er) {
callback(er)
})
},
// load everything
function(callback) {
settings = require('./utils/Settings');
db = require('./db/DB');
plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
hooks.plugins = plugins;
//set loglevel
log4js.setGlobalLogLevel(settings.loglevel);
callback();
},
//initalize the database //initalize the database
function (callback) function (callback)
{ {
db.init(callback); db.init(callback);
}, },
plugins.update, function(callback) {
plugins.update(callback)
},
function (callback) { function (callback) {
console.info("Installed plugins: " + plugins.formatPlugins()); console.info("Installed plugins: " + plugins.formatPlugins());