+ return res.json(plugin.toFormattedJSON())
+ } catch (err) {
+ logger.warn('Cannot install plugin %s.', toInstall, { err })
+ return res.fail({ message: 'Cannot install plugin ' + toInstall })
+ }
+}
+
+async function updatePlugin (req: express.Request, res: express.Response) {
+ const body: InstallOrUpdatePlugin = req.body
+
+ const fromDisk = !!body.path
+ const toUpdate = body.npmName || body.path
+ try {
+ const plugin = await PluginManager.Instance.update(toUpdate, fromDisk)
+
+ return res.json(plugin.toFormattedJSON())
+ } catch (err) {
+ logger.warn('Cannot update plugin %s.', toUpdate, { err })
+ return res.fail({ message: 'Cannot update plugin ' + toUpdate })
+ }