Mimic, replace or work around removed npm utils.

This commit is contained in:
Marcel Klehr 2012-10-28 18:34:20 +01:00
parent e447a6fade
commit 78e64ffea8
4 changed files with 24 additions and 7 deletions

View File

@ -27,6 +27,7 @@
"jsdom-nocontextifiy" : "0.2.10",
"async-stacktrace" : "0.0.2",
"npm" : "1.1.x",
"npm-registry-client" : "0.2.10",
"ejs" : "0.6.1",
"graceful-fs" : "1.1.5",
"slide" : "1.1.3",

View File

@ -1,7 +1,12 @@
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
var npm = require("npm");
var registry = require("npm/lib/utils/npm-registry-client/index.js");
var RegClient = require("npm-registry-client")
var registry = new RegClient(
{ registry: "http://registry.npmjs.org"
, cache: npm.cache }
);
var withNpm = function (npmfn, final, cb) {
npm.load({}, function (er) {
@ -72,7 +77,7 @@ exports.search = function(query, cache, cb) {
cb(null, exports.searchCache);
} else {
registry.get(
"/-/all", null, 600, false, true,
"/-/all", 600, false, true,
function (er, data) {
if (er) return cb(er);
exports.searchCache = data;

View File

@ -1,7 +1,5 @@
var npm = require("npm/lib/npm.js");
var readInstalled = require("./read-installed.js");
var relativize = require("npm/lib/utils/relativize.js");
var readJson = require("npm/lib/utils/read-json.js");
var path = require("path");
var async = require("async");
var fs = require("fs");

View File

@ -94,8 +94,21 @@ var npm = require("npm/lib/npm.js")
, path = require("path")
, asyncMap = require("slide").asyncMap
, semver = require("semver")
, readJson = require("npm/lib/utils/read-json.js")
, log = require("npm/lib/utils/log.js")
, log = require("log4js").getLogger('pluginfw')
function readJson(file, callback) {
fs.readFile(file, function(er, buf) {
if(er) {
callback(er);
return;
}
try {
callback( null, JSON.parse(buf.toString()) )
} catch(er) {
callback(er)
}
})
}
module.exports = readInstalled
@ -274,7 +287,7 @@ function findUnmet (obj) {
}
})
log.verbose([obj._id], "returning")
log.debug([obj._id], "returning")
return obj
}