Skip to content

Commit

Permalink
Add options.suffix (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhenderson committed Sep 1, 2021
1 parent 1dddd09 commit 589178d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ test("updateTypes", async function () {
output,
overrides,
prefix: 'import { PostgresInterval} from "postgres-interval";',
suffix: '// user supplied suffix',
schema: ["public", "log", "!secret"],
exclude: ["login"],
});
Expand Down Expand Up @@ -159,6 +160,7 @@ test("updateTypes", async function () {
interval: PostgresInterval;
};
// user supplied suffix
"
`);
});
Expand Down
7 changes: 7 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type Options = {
overrides?: Record<string, string>;

prefix?: string;
suffix?: string;

/**
* Schemas that should be included/excluded when generating types.
Expand Down Expand Up @@ -183,6 +184,12 @@ export async function updateTypes(db: Knex, options: Options): Promise<void> {
output.write("};\n\n");
}
});

if (options.suffix) {
output.write(options.suffix);
output.write("\n")
}

} finally {
output.end();
db.destroy();
Expand Down

0 comments on commit 589178d

Please sign in to comment.