Merge pull request #593 from fourplusone/nicer_code
Removing node.extend
This commit is contained in:
commit
e387e25c05
|
@ -25,7 +25,6 @@
|
|||
"async-stacktrace" : "0.0.2",
|
||||
"npm" : "1.1",
|
||||
"ejs" : "0.6.1",
|
||||
"node.extend" : "1.0.0",
|
||||
"graceful-fs" : "1.1.5",
|
||||
"slide" : "1.1.3",
|
||||
"semver" : "1.0.13",
|
||||
|
|
|
@ -12,10 +12,9 @@ if (!exports.isClient) {
|
|||
var fs = require("fs");
|
||||
var tsort = require("./tsort");
|
||||
var util = require("util");
|
||||
var extend = require("node.extend");
|
||||
_ = require("underscore");
|
||||
}else{
|
||||
var $, jQuery
|
||||
var $, jQuery;
|
||||
$ = jQuery = require("ep_etherpad-lite/static/js/rjquery").$;
|
||||
_ = require("ep_etherpad-lite/static/js/underscore");
|
||||
}
|
||||
|
@ -31,15 +30,15 @@ exports.ensure = function (cb) {
|
|||
exports.update(cb);
|
||||
else
|
||||
cb();
|
||||
}
|
||||
};
|
||||
|
||||
exports.formatPlugins = function () {
|
||||
return _.keys(exports.plugins).join(", ");
|
||||
}
|
||||
};
|
||||
|
||||
exports.formatParts = function () {
|
||||
return _.map(exports.parts, function (part) { return part.full_name; }).join("\n");
|
||||
}
|
||||
};
|
||||
|
||||
exports.formatHooks = function () {
|
||||
var res = [];
|
||||
|
@ -49,7 +48,7 @@ exports.formatHooks = function () {
|
|||
});
|
||||
});
|
||||
return res.join("\n");
|
||||
}
|
||||
};
|
||||
|
||||
exports.loadFn = function (path) {
|
||||
var x = path.split(":");
|
||||
|
@ -58,7 +57,7 @@ exports.loadFn = function (path) {
|
|||
fn = fn[name];
|
||||
});
|
||||
return fn;
|
||||
}
|
||||
};
|
||||
|
||||
exports.extractHooks = function (parts, hook_set_name) {
|
||||
var hooks = {};
|
||||
|
@ -75,7 +74,7 @@ exports.extractHooks = function (parts, hook_set_name) {
|
|||
});
|
||||
});
|
||||
return hooks;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (exports.isClient) {
|
||||
|
@ -90,7 +89,7 @@ if (exports.isClient) {
|
|||
console.error("Failed to load plugin-definitions: " + err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
||||
exports.update = function (cb) {
|
||||
|
@ -112,7 +111,7 @@ exports.update = function (cb) {
|
|||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.getPackages = function (cb) {
|
||||
// Load list of installed NPM packages, flatten it to a list, and filter out only packages with names that
|
||||
|
@ -122,25 +121,26 @@ exports.getPackages = function (cb) {
|
|||
var packages = {};
|
||||
function flatten(deps) {
|
||||
_.chain(deps).keys().each(function (name) {
|
||||
if (name.indexOf(exports.prefix) == 0) {
|
||||
packages[name] = extend({}, deps[name]);
|
||||
if (name.indexOf(exports.prefix) === 0) {
|
||||
packages[name] = _.clone(deps[name]);
|
||||
// Delete anything that creates loops so that the plugin
|
||||
// list can be sent as JSON to the web client
|
||||
delete packages[name].dependencies;
|
||||
delete packages[name].parent;
|
||||
}
|
||||
if (deps[name].dependencies !== undefined)
|
||||
flatten(deps[name].dependencies);
|
||||
|
||||
if (deps[name].dependencies !== undefined) flatten(deps[name].dependencies);
|
||||
});
|
||||
}
|
||||
|
||||
var tmp = {};
|
||||
tmp[data.name] = data;
|
||||
flatten(tmp);
|
||||
cb(null, packages);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
|
||||
exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
|
||||
var plugin_path = path.resolve(packages[plugin_name].path, "ep.json");
|
||||
fs.readFile(
|
||||
plugin_path,
|
||||
|
@ -151,7 +151,7 @@ exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
|
|||
}
|
||||
try {
|
||||
var plugin = JSON.parse(data);
|
||||
plugin.package = packages[plugin_name];
|
||||
plugin['package'] = packages[plugin_name];
|
||||
plugins[plugin_name] = plugin;
|
||||
_.each(plugin.parts, function (part) {
|
||||
part.plugin = plugin_name;
|
||||
|
@ -164,7 +164,7 @@ exports.loadPlugin = function (packages, plugin_name, plugins, parts, cb) {
|
|||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
exports.partsToParentChildList = function (parts) {
|
||||
var res = [];
|
||||
|
@ -180,7 +180,7 @@ exports.partsToParentChildList = function (parts) {
|
|||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Used only in Node, so no need for _
|
||||
|
|
Loading…
Reference in New Issue