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

pull/1096/head
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.
*/
var log4js = require('log4js')
, async = require('async')
;
// set up logger
var log4js = require('log4js');
log4js.replaceConsole();
var settings = require('./utils/Settings');
//set loglevel
log4js.setGlobalLogLevel(settings.loglevel);
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 settings
, db
, plugins
, hooks;
var npm = require("npm/lib/npm.js");
hooks.plugins = plugins;
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
function (callback)
{
db.init(callback);
},
plugins.update,
function(callback) {
plugins.update(callback)
},
function (callback) {
console.info("Installed plugins: " + plugins.formatPlugins());