Skip to content

Commit

Permalink
Make sure to write the index file too
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbieMcKinstry committed Oct 6, 2022
1 parent 6bea465 commit 83109f8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/codegen/nodejs/gen.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 83109f8

Please sign in to comment.