Skip to content

Commit f084ebe

Browse files
sammwafyeddeee888
andauthored
Filter empty files to prevent GraphQL codegen plugin configuration errors (#393)
* fix(preset): use correct plugin reference in pluginMap and skip empty files * Add chanageset * Set up test for empty file case * Format --------- Co-authored-by: Eddy Nguyen <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
1 parent 96dad19 commit f084ebe

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

.changeset/every-sites-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@eddeee888/gcg-operation-location-migration': patch
3+
---
4+
5+
Fix empty file breaking codemod

packages/operation-location-migration-e2e/src/test-apollo-support/components/Empty.ts

Whitespace-only changes.

packages/operation-location-migration/src/preset.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,19 @@ export const preset: Types.OutputPreset<TypedPresetConfig> = {
351351
);
352352
});
353353

354-
return tsProject.getSourceFiles().map((tsSourceFile) => {
355-
return {
356-
filename: tsSourceFile.getFilePath(),
357-
pluginMap: { add: addPlugin },
358-
plugins: [{ add: { content: tsSourceFile.getFullText() } }],
359-
config: {},
360-
schema,
361-
documents: [],
362-
};
363-
});
354+
return tsProject
355+
.getSourceFiles()
356+
.filter((sf) => sf.getFullText().trim().length > 0)
357+
.map((tsSourceFile) => {
358+
return {
359+
filename: tsSourceFile.getFilePath(),
360+
pluginMap: { add: addPlugin },
361+
plugins: [{ add: { content: tsSourceFile.getFullText() } }],
362+
config: {},
363+
schema,
364+
documents: [],
365+
};
366+
});
364367
},
365368
};
366369

0 commit comments

Comments
 (0)