2015-08-19 15:21:08 +00:00
|
|
|
(function() {
|
2015-10-06 22:51:17 +00:00
|
|
|
var _, capitano, nplugm, patterns;
|
2015-08-19 15:21:08 +00:00
|
|
|
|
|
|
|
nplugm = require('nplugm');
|
|
|
|
|
|
|
|
_ = require('lodash');
|
|
|
|
|
|
|
|
capitano = require('capitano');
|
|
|
|
|
2015-10-06 22:51:17 +00:00
|
|
|
patterns = require('./patterns');
|
|
|
|
|
2015-08-19 15:21:08 +00:00
|
|
|
exports.register = function(regex) {
|
|
|
|
return nplugm.list(regex).map(function(plugin) {
|
|
|
|
var command;
|
|
|
|
command = require(plugin);
|
2015-10-01 14:39:36 +00:00
|
|
|
command.plugin = true;
|
2015-08-19 15:21:08 +00:00
|
|
|
if (!_.isArray(command)) {
|
|
|
|
return capitano.command(command);
|
|
|
|
}
|
|
|
|
return _.each(command, capitano.command);
|
|
|
|
})["catch"](function(error) {
|
2015-10-06 22:51:17 +00:00
|
|
|
return patterns.printErrorMessage(error.message);
|
2015-08-19 15:21:08 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
}).call(this);
|