Skip to content

Commit

Permalink
fix: base fixing path metadata on existing paths
Browse files Browse the repository at this point in the history
  • Loading branch information
m-radzikowski committed Oct 21, 2024
1 parent 0ceec80 commit cc2b037
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/fixPathsMetadataAspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import {IConstruct} from 'constructs';

export class FixPathsMetadataAspect implements IAspect {
public visit(node: IConstruct): void {
const possibleL1 = node.node.defaultChild ? node.node.defaultChild : node;
if (possibleL1 instanceof CfnResource && node.node.path) {
if (node instanceof CfnResource && typeof node.getMetadata('aws:cdk:path') === 'string') {
const stackId = Stack.of(node).node.id;
const parts = node.node.path.split('/');
const parts = (node.getMetadata('aws:cdk:path') as string).split('/');
if (parts.indexOf(stackId) !== -1) {
possibleL1.addMetadata('aws:cdk:path', parts.slice(parts.indexOf(stackId)).join('/'));
node.addMetadata('aws:cdk:path', parts.slice(parts.indexOf(stackId)).join('/'));
}
}
}
Expand Down

0 comments on commit cc2b037

Please sign in to comment.