balena-cli/lib/plugins.coffee

35 lines
749 B
CoffeeScript
Raw Normal View History

2015-02-24 17:36:10 +00:00
Nplugm = require('nplugm')
2015-02-10 15:46:22 +00:00
_ = require('lodash')
capitano = require('capitano')
2015-02-24 17:36:10 +00:00
nplugm = null
2015-02-10 15:46:22 +00:00
registerPlugin = (plugin) ->
return capitano.command(plugin) if not _.isArray(plugin)
return _.each(plugin, capitano.command)
2015-02-24 17:36:10 +00:00
exports.register = (prefix, callback) ->
nplugm = new Nplugm(prefix)
nplugm.list (error, plugins) ->
2015-02-12 17:09:45 +00:00
return callback(error) if error?
2015-02-24 17:36:10 +00:00
for plugin in plugins
try
registerPlugin(nplugm.require(plugin))
catch error
console.error(error.message)
2015-02-12 17:09:45 +00:00
2015-02-24 17:36:10 +00:00
return callback()
2015-02-12 17:09:45 +00:00
2015-02-24 17:36:10 +00:00
exports.list = ->
nplugm.list.apply(nplugm, arguments)
2015-02-12 17:09:45 +00:00
2015-02-24 17:36:10 +00:00
exports.install = ->
nplugm.install.apply(nplugm, arguments)
2015-02-12 17:09:45 +00:00
2015-03-02 14:41:08 +00:00
exports.update = ->
nplugm.update.apply(nplugm, arguments)
2015-02-24 17:36:10 +00:00
exports.remove = ->
nplugm.remove.apply(nplugm, arguments)