Skip to content

Commit

Permalink
fix(go): Submodule File Paths (#2147)
Browse files Browse the repository at this point in the history
fix(go): Submodule File Paths

Fixes go code generation for submodules. File paths were only nesting
for immediate children and not deeply nested ones.

---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
MrArnoldPalmer authored Oct 20, 2020
1 parent 21c6fb5 commit 8863493
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
11 changes: 6 additions & 5 deletions packages/jsii-pacmak/lib/targets/go/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export abstract class Package {
const moduleName = pack.root.moduleName;
const prefix = moduleName !== '' ? `${moduleName}/` : '';
const rootPackageName = pack.root.packageName;
const suffix = pack.filePath !== '' ? `/${pack.filePath}` : '';
const suffix = pack.filePath !== '' ? `/${pack.filePath}` : ``;
return `${prefix}${rootPackageName}${suffix}`;
}),
);
Expand Down Expand Up @@ -258,11 +258,12 @@ export class RootPackage extends Package {
* InternalPackage refers to any go package within a given JSII module.
*/
export class InternalPackage extends Package {
public readonly pkg: Package;
public readonly parent: Package;

public constructor(root: Package, pkg: Package, assembly: JsiiSubmodule) {
public constructor(root: Package, parent: Package, assembly: JsiiSubmodule) {
const packageName = goPackageName(assembly.name);
const filePath = pkg === root ? packageName : pkg.filePath;
const filePath =
parent === root ? packageName : `${parent.filePath}/${packageName}`;

super(
assembly.types,
Expand All @@ -273,6 +274,6 @@ export class InternalPackage extends Package {
root,
);

this.pkg = pkg;
this.parent = parent;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8863493

Please sign in to comment.