You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/09/11 20:55:29 UTC
git commit: [CB-4793] Lazily require modules in plugin.js
Updated Branches:
refs/heads/master 6486e7fda -> b5ba62d82
[CB-4793] Lazily require modules in plugin.js
Cuts ~350ms off of many commands on my MBP.
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/b5ba62d8
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/b5ba62d8
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/b5ba62d8
Branch: refs/heads/master
Commit: b5ba62d8225e8b00c45f11e288e041a073f3f323
Parents: 6486e7f
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Sep 11 14:54:28 2013 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Sep 11 14:55:14 2013 -0400
----------------------------------------------------------------------
plugman.js | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b5ba62d8/plugman.js
----------------------------------------------------------------------
diff --git a/plugman.js b/plugman.js
index 4ca7846..b9748ac 100755
--- a/plugman.js
+++ b/plugman.js
@@ -21,24 +21,29 @@
var emitter = require('./src/events');
+function addProperty(o, symbol, modulePath) {
+ Object.defineProperty(o, symbol, {
+ get : function() { return require(modulePath); }});
+}
+
plugman = {
- help: require('./src/help'),
- install: require('./src/install'),
- uninstall: require('./src/uninstall'),
- fetch: require('./src/fetch'),
- prepare: require('./src/prepare'),
- config: require('./src/config'),
- adduser: require('./src/adduser'),
- publish: require('./src/publish'),
- unpublish: require('./src/unpublish'),
- search: require('./src/search'),
- info: require('./src/info'),
- config_changes: require('./src/util/config-changes'),
on: emitter.addListener,
off: emitter.removeListener,
removeAllListeners: emitter.removeAllListeners,
emit: emitter.emit
};
+addProperty(plugman, 'help', './src/help');
+addProperty(plugman, 'install', './src/install');
+addProperty(plugman, 'uninstall', './src/uninstall');
+addProperty(plugman, 'fetch', './src/fetch');
+addProperty(plugman, 'prepare', './src/prepare');
+addProperty(plugman, 'config', './src/config');
+addProperty(plugman, 'adduser', './src/adduser');
+addProperty(plugman, 'publish', './src/publish');
+addProperty(plugman, 'unpublish', './src/unpublish');
+addProperty(plugman, 'search', './src/search');
+addProperty(plugman, 'info', './src/info');
+addProperty(plugman, 'config_changes', './src/util/config-changes');
plugman.commands = {
'config' : function(cli_opts) {