From 1a0f849bb9443098114c92b76a9a84bd4d19fc9d Mon Sep 17 00:00:00 2001 From: Robbie McKinstry Date: Thu, 6 Oct 2022 10:26:14 -0400 Subject: [PATCH] Make sure to write the index file too --- pkg/codegen/nodejs/gen.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/codegen/nodejs/gen.go b/pkg/codegen/nodejs/gen.go index 7c0c5ffa225c..00fc3db1fa30 100644 --- a/pkg/codegen/nodejs/gen.go +++ b/pkg/codegen/nodejs/gen.go @@ -1751,6 +1751,21 @@ func (ns *namespace) intoIOFiles(ctx *ioContext, parent string) ([]*ioFile, erro files = append(files, nestedFiles...) } + // Lastly, we write the index file for this directory once. + // We don't want to generate the file twice, when this function is called + // with input=true and again when input=false, so we only generate it + // when input=true. + // As a special case, we skip the top-level directory /types/, since that + // is written elsewhere. + if parent != "./types" && ctx.input { + var indexPath = path.Join(dirRoot, "index.ts") + var file = newIOFile(indexPath) + ctx.mod.genHeader(file.writer(), nil, nil, nil) + fmt.Fprintf(file.writer(), "export * from \"./%s\";\n", "input.ts") + fmt.Fprintf(file.writer(), "export * from \"./%s\";\n", "output.ts") + files = append(files, file) + } + return files, nil }