Skip to content

Commit cc2b037

Browse files
committed
fix: base fixing path metadata on existing paths
1 parent 0ceec80 commit cc2b037

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/fixPathsMetadataAspect.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import {IConstruct} from 'constructs';
33

44
export class FixPathsMetadataAspect implements IAspect {
55
public visit(node: IConstruct): void {
6-
const possibleL1 = node.node.defaultChild ? node.node.defaultChild : node;
7-
if (possibleL1 instanceof CfnResource && node.node.path) {
6+
if (node instanceof CfnResource && typeof node.getMetadata('aws:cdk:path') === 'string') {
87
const stackId = Stack.of(node).node.id;
9-
const parts = node.node.path.split('/');
8+
const parts = (node.getMetadata('aws:cdk:path') as string).split('/');
109
if (parts.indexOf(stackId) !== -1) {
11-
possibleL1.addMetadata('aws:cdk:path', parts.slice(parts.indexOf(stackId)).join('/'));
10+
node.addMetadata('aws:cdk:path', parts.slice(parts.indexOf(stackId)).join('/'));
1211
}
1312
}
1413
}

0 commit comments

Comments
 (0)