Add unit tests for externalModules

This commit is contained in:
Nick O'Leary
2021-02-15 17:28:14 +00:00
parent d2c9ccbfdd
commit 05beb6ca79
2 changed files with 292 additions and 9 deletions

View File

@@ -41,8 +41,8 @@ async function refreshExternalModules() {
function init(_settings) {
settings = _settings;
path.resolve(settings.userDir || process.env.NODE_RED_HOME || ".");
knownExternalModules = {};
installEnabled = true;
if (settings.externalModules && settings.externalModules.modules) {
if (settings.externalModules.modules.allowList || settings.externalModules.modules.denyList) {
installAllowList = settings.externalModules.modules.allowList;
@@ -197,7 +197,6 @@ async function installModule(moduleDetails) {
}).catch(result => {
var output = result.stderr;
var e;
var lookForVersionNotFound = new RegExp("version not found: ","m");
if (/E404/.test(output) || /ETARGET/.test(output)) {
log.error(log._("server.install.install-failed-not-found",{name:installSpec}));
e = new Error("Module not found");
@@ -208,7 +207,9 @@ async function installModule(moduleDetails) {
log.error("------------------------------------------");
log.error(output);
log.error("------------------------------------------");
throw new Error(log._("server.install.install-failed"));
e = new Error(log._("server.install.install-failed"));
e.code = "unexpected_error";
throw e;
}
})
}