mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 06:57:48 +00:00
32 lines
688 B
CoffeeScript
32 lines
688 B
CoffeeScript
Nplugm = require('nplugm')
|
|
_ = require('lodash')
|
|
capitano = require('capitano')
|
|
|
|
nplugm = null
|
|
|
|
registerPlugin = (plugin) ->
|
|
return capitano.command(plugin) if not _.isArray(plugin)
|
|
return _.each(plugin, capitano.command)
|
|
|
|
exports.register = (prefix, callback) ->
|
|
nplugm = new Nplugm(prefix)
|
|
nplugm.list (error, plugins) ->
|
|
return callback(error) if error?
|
|
|
|
for plugin in plugins
|
|
try
|
|
registerPlugin(nplugm.require(plugin))
|
|
catch error
|
|
console.error(error.message)
|
|
|
|
return callback()
|
|
|
|
exports.list = ->
|
|
nplugm.list.apply(nplugm, arguments)
|
|
|
|
exports.install = ->
|
|
nplugm.install.apply(nplugm, arguments)
|
|
|
|
exports.remove = ->
|
|
nplugm.remove.apply(nplugm, arguments)
|