Skip to content

Commit

Permalink
changed to use reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffCoxMSFT committed Apr 2, 2021
1 parent 1245eea commit d16974c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions extensions/azurePublish/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,13 @@ export default async (composer: IExtensionRegistration): Promise<void> => {

// verify the publish profile has the required resources configured
const resources = await this.getResources(project, user);
const missingResourceNames = [];
resources
.filter((r) => r.required)
.forEach((r) => {
if (!this.isResourceProvisionedInProfile(r, config)) {
missingResourceNames.push(r.text);
}
});

const missingResourceNames = resources.reduce((result, resource) => {
if (resource.required && !this.isResourceProvisionedInProfile(resource, config)) {
result.push(resource.text);
}
return result;
}, []);

if (missingResourceNames.length > 0) {
const missingResourcesText = missingResourceNames.join(',');
Expand Down Expand Up @@ -745,7 +744,9 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
case AzureResourceTypes.WEBAPP:
return profile?.hostname;
default:
throw new Error(`Azure resource type ${resource.key} is not handled.`);
throw new Error(
formatMessage('Azure resource type {resourceKey} is not handled.', { resourceKey: resource.key })
);
}
};

Expand Down

0 comments on commit d16974c

Please sign in to comment.