Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async addModule(pkgname: string) {
try {
const info: {nodes: any} = await registry.addModule(pkgname);
RED.runtime.events.emit("runtime-event", {
id: "node/added",
payload: info.nodes,
retain: false
});
} catch (err) {
if (err.code === "module_already_loaded") {
this.error(err, `${pkgname} already loaded`);
return;
}
if (err.code !== "MODULE_NOT_FOUND") throw err;
this.success(`${pkgname} installed`);
}
}