From 7ec7ccc4022dc565dba43d7bc22953844b9f4f91 Mon Sep 17 00:00:00 2001 From: mluto Date: Sun, 6 Jan 2013 19:25:32 +0100 Subject: [PATCH 1/2] Fixed extractPadData.js, #1320 --- bin/extractPadData.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/bin/extractPadData.js b/bin/extractPadData.js index 061a2e3f..18f1f76c 100644 --- a/bin/extractPadData.js +++ b/bin/extractPadData.js @@ -10,17 +10,26 @@ if(process.argv.length != 3) //get the padID var padId = process.argv[2]; -//initalize the database -var log4js = require("log4js"); -log4js.setGlobalLogLevel("INFO"); -var async = require("async"); -var db = require('../node/db/DB'); -var dirty = require("dirty")(padId + ".db"); -var padManager; -var pad; +var db, dirty, padManager, pad; var neededDBValues = ["pad:"+padId]; +var npm = require("../src/node_modules/npm"); +var async = require("../src/node_modules/async"); +var log4js = require("../src/node_modules/log4js"); +log4js.setGlobalLogLevel("INFO"); + async.series([ + // load npm + function(callback) { + npm.load({}, function(er) { + callback(er) + }) + }, + // load modules + function(callback) { + db = require('../src/node/db/DB'); + dirty = require("../src/node_modules/ueberDB/node_modules/dirty")(padId + ".db"); + }, //intallize the database function (callback) { From e7d9359737d40aa2168b60ac02c14b88a4e8cc8e Mon Sep 17 00:00:00 2001 From: mluto Date: Sun, 6 Jan 2013 20:20:46 +0100 Subject: [PATCH 2/2] Added error-handling for npm --- bin/extractPadData.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/extractPadData.js b/bin/extractPadData.js index 18f1f76c..f79b964a 100644 --- a/bin/extractPadData.js +++ b/bin/extractPadData.js @@ -22,7 +22,15 @@ async.series([ // load npm function(callback) { npm.load({}, function(er) { - callback(er) + if(er) + { + console.error("Could not load NPM: " + er) + process.exit(1); + } + else + { + callback(); + } }) }, // load modules