Skip to content

Commit

Permalink
install default packages in parallel (#67893) (#67942)
Browse files Browse the repository at this point in the history
  • Loading branch information
neptunian committed Jun 2, 2020
1 parent a26ccf3 commit 301372e
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@ export async function ensureInstalledDefaultPackages(
const installations = [];
for (const pkgName in DefaultPackages) {
if (!DefaultPackages.hasOwnProperty(pkgName)) continue;
const installation = await ensureInstalledPackage({
const installation = ensureInstalledPackage({
savedObjectsClient,
pkgName,
callCluster,
});
if (installation) installations.push(installation);
installations.push(installation);
}

return installations;
return Promise.all(installations);
}

export async function ensureInstalledPackage(options: {
savedObjectsClient: SavedObjectsClientContract;
pkgName: string;
callCluster: CallESAsCurrentUser;
}): Promise<Installation | undefined> {
}): Promise<Installation> {
const { savedObjectsClient, pkgName, callCluster } = options;
const installedPackage = await getInstallation({ savedObjectsClient, pkgName });
if (installedPackage) {
Expand All @@ -79,7 +79,9 @@ export async function ensureInstalledPackage(options: {
pkgName,
callCluster,
});
return await getInstallation({ savedObjectsClient, pkgName });
const installation = await getInstallation({ savedObjectsClient, pkgName });
if (!installation) throw new Error(`could not get installation ${pkgName}`);
return installation;
}

export async function installPackage(options: {
Expand Down

0 comments on commit 301372e

Please sign in to comment.