Skip to content

Commit

Permalink
fix(cli): add defensive coding to isContainersEnabled() (#6758)
Browse files Browse the repository at this point in the history
This commit adds optional chaining and nullish coalescing to the
isContainersEnabled() function. It also stores the project config
in a variable instead of parsing it multiple times.
  • Loading branch information
cjihrig committed Mar 2, 2021
1 parent 9dc49f5 commit 78bb42d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/amplify-cli/src/execution-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,8 @@ export async function executeCommand(context: Context) {
}

function isContainersEnabled(context) {
const { frontend } = context.amplify.getProjectConfig();
if (frontend) {
const { config: { ServerlessContainers = false } = {} } = context.amplify.getProjectConfig()[frontend];

return ServerlessContainers;
}

return false;
const projectConfig = context.amplify.getProjectConfig();
return projectConfig?.[projectConfig.frontend]?.config?.ServerlessContainers ?? false;
}

async function selectPluginForExecution(context: Context, pluginCandidates: PluginInfo[]): Promise<PluginInfo> {
Expand Down

0 comments on commit 78bb42d

Please sign in to comment.