Skip to content

Commit

Permalink
fix: find all stacks with github
Browse files Browse the repository at this point in the history
  • Loading branch information
ap0nia committed Jul 16, 2023
1 parent 3a159d5 commit 2e22aa2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/ant-stack/src/cdk/constructs/github/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,19 @@ export class GitHub<T extends Outputs = Outputs> extends Construct {
export async function getGitHub(initializedApp?: App): Promise<GitHub> {
const app = initializedApp ?? (await synthesizeConfig());

const stacks = app.node.children.find(Stack.isStack);
const stacks = app.node.children.filter(Stack.isStack);

if (!stacks) {
throw new Error(`No stacks found.`);
}

const gitHub = stacks?.node.children.find(GitHub.isGitHub);
const stackWithGitHub = stacks.find((stack) => stack.node.children.some(GitHub.isGitHub));

if (!gitHub) {
const github = stackWithGitHub?.node.children.find(GitHub.isGitHub);

if (!github) {
throw new Error(`No ${GitHub.type} construct found.`);
}

return gitHub;
return github;
}

0 comments on commit 2e22aa2

Please sign in to comment.