Skip to content

Commit 84c8258

Browse files
author
Steven Petryk
authored
fix: prevent duplicated headers in generated files (#29)
Just a bad merge led to this, I think. Closes #28
1 parent b05c174 commit 84c8258

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

Diff for: src/renderers/render.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ export default async function render(
2424
const sortedLocales = locales.sort((a, b) => a.code.localeCompare(b.code))
2525

2626
const typingsSource = [
27-
renderContentfulImports(localization),
2827
renderAllContentTypes(sortedContentTypes, localization),
2928
renderAllContentTypeIds(sortedContentTypes),
3029
renderAllLocales(sortedLocales),
3130
renderDefaultLocale(sortedLocales),
3231
renderLocalizedTypes(localization),
3332
].join("\n\n")
3433

35-
const source = [renderContentfulImports(), renderNamespace(typingsSource, namespace)].join("\n\n")
34+
const source = [
35+
renderContentfulImports(localization),
36+
renderNamespace(typingsSource, namespace),
37+
].join("\n\n")
3638

3739
const prettierConfig = await resolveConfig(process.cwd())
3840
return format(source, { ...prettierConfig, parser: "typescript" })

Diff for: test/renderers/render.test.ts

-15
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ describe("render()", () => {
5858
import { Asset, Entry } from \\"contentful\\"
5959
import { Document } from \\"@contentful/rich-text-types\\"
6060
61-
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.
62-
63-
import { Asset, Entry } from \\"contentful\\"
64-
import { Document } from \\"@contentful/rich-text-types\\"
65-
6661
export interface IMyContentTypeFields {
6762
/** Array field */
6863
arrayField: (\\"one\\" | \\"of\\" | \\"the\\" | \\"above\\")[]
@@ -130,11 +125,6 @@ describe("render()", () => {
130125
expect(await render(contentTypes, locales, { localization: true })).toMatchInlineSnapshot(`
131126
"// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.
132127
133-
import { Asset, Entry } from \\"contentful\\"
134-
import { Document } from \\"@contentful/rich-text-types\\"
135-
136-
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.
137-
138128
import { Entry } from \\"contentful\\"
139129
import { Document } from \\"@contentful/rich-text-types\\"
140130
@@ -201,11 +191,6 @@ describe("render()", () => {
201191
import { Document } from \\"@contentful/rich-text-types\\"
202192
203193
declare namespace Codegen {
204-
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY IT.
205-
206-
import { Asset, Entry } from \\"contentful\\"
207-
import { Document } from \\"@contentful/rich-text-types\\"
208-
209194
export interface IMyContentTypeFields {
210195
/** Array field */
211196
arrayField: (\\"one\\" | \\"of\\" | \\"the\\" | \\"above\\")[]

0 commit comments

Comments
 (0)