Permalink
Browse files

cleanup

  • Loading branch information...
1 parent 04d4c50 commit aa0a621d677cba12b7ca5658eff9faf649de2fb9 @crcn crcn committed Feb 23, 2013
View
@@ -6,28 +6,41 @@ exports.plugin = function(cli, loader) {
- function getHandler(type) {
- handlers = loader.modules("command.*");
- for(var i = handlers.length; i--;) {
- var handler = handlers[i];
+ function getHandler(type, callback) {
+ loader.loadModules("^command.*$", function(err, handlers) {
+ for(var i = handlers.length; i--;) {
+ var handler = handlers[i];
+ if(handler.testListener && handler.testListener(type)) return callback(null, handler);
+ }
+
+ callback();
+ });
- if(handler.testListener(type)) return handler;
- }
}
cli.emit = function(buffer, data) {
- try {
- var handler = getHandler(buffer);
+ var ret = true;
+
+ //fucking dirty... - this is synchronous.
+ getHandler(buffer, function(err, handler) {
+ try {
+
+ if(!handler) {
+ ret = false;
+ return;
+ }
+
- if(!handler) return false;
+ return handler.run(buffer, data);
- return handler.run(buffer, data);
+ } catch(e) {
+ console.error(e.stack);
+ ret = false;
+ }
+ });
- } catch(e) {
- console.error(e.stack);
- return false;
- }
+ return ret;
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit aa0a621

Please sign in to comment.