Read plugin name from package.json

This commit is contained in:
Asher 2020-10-07 12:54:40 -05:00
parent c2ac126a50
commit a44b4455f5
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 4 additions and 2 deletions

View File

@ -35,10 +35,12 @@ const loadPlugin = async (pluginPath: string, httpServer: HttpServer, args: Args
const plugin: Plugin = require(pluginPath) const plugin: Plugin = require(pluginPath)
plugin.activate(httpServer, args) plugin.activate(httpServer, args)
const packageJson = require(path.join(pluginPath, "package.json"))
logger.debug( logger.debug(
"Loaded plugin", "Loaded plugin",
field("name", path.basename(pluginPath)), field("name", packageJson.name || path.basename(pluginPath)),
field("version", require(path.join(pluginPath, "package.json")).version || "n/a"), field("path", pluginPath),
field("version", packageJson.version || "n/a"),
) )
} catch (error) { } catch (error) {
logger.error(error.message) logger.error(error.message)