Skip to content

Commit

Permalink
Sending error code if module not properly installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Fgerthoffert committed Mar 31, 2021
1 parent 393d48e commit ac899f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/modules/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import getModules from '../utils/get-modules';
import shouldInstall from '../utils/should-install';
import installMod from '../utils/install-module';
import uninstallMod from '../utils/uninstall-module';
import { sleep } from '../../../utils'

/* eslint max-params: ["error", 5] */
const installModule = async (
Expand Down Expand Up @@ -96,13 +97,19 @@ const installModule = async (
await uninstallMod(flags.jahiaAdminUrl, flags.jahiaAdminUsername, flags.jahiaAdminPassword, mod.key);
}
}
await sleep(1000);
const postInstallModules = await getModules(
flags.jahiaAdminUrl,
flags.jahiaAdminUsername,
flags.jahiaAdminPassword
);
console.log(`${new Date().toISOString()} - The following modules have been detected on the platform for id: ${moduleId}`);
console.log(postInstallModules.filter((m: any) => m.id === installedModule[0].symbolicName))
console.log(`${new Date().toISOString()} - The following modules have been detected on the platform for id: ${moduleId}`);
const detectedModule = postInstallModules.filter((m: any) => m.id === installedModule[0].symbolicName)
console.log(detectedModule)
if (detectedModule.length === 0) {
console.log(`${new Date().toISOString()} - ERROR: Could not detect module ${moduleId} on the platform, there was likely an issue during module provisioning. EXITING`);
exit(1)
}
}
} else {
console.log(`${new Date().toISOString()} - Module already installed`);
Expand Down
1 change: 1 addition & 0 deletions src/components/modules/utils/should-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const shouldInstall = (installedModules: Array<any>, moduleId: string, moduleVer
// Search for the module ID in the list of installed modules
const installedModule = installedModules.find((m) => m.id === moduleId)
if (installedModule === undefined) {
console.log(`${new Date().toISOString()} - The module ${moduleId} was not detected on the remote Jahia`)
return true
}

Expand Down

0 comments on commit ac899f3

Please sign in to comment.