From 2dbb927779e4ada2c6aff47c4027d770365e1003 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Mon, 14 Apr 2025 23:16:04 +1000 Subject: [PATCH 1/2] Treat windows and unix line ending the same whilst doing hash content check --- packages/graphql-codegen-cli/src/generate-and-save.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/graphql-codegen-cli/src/generate-and-save.ts b/packages/graphql-codegen-cli/src/generate-and-save.ts index b95511219b7..9ddc20ebf66 100644 --- a/packages/graphql-codegen-cli/src/generate-and-save.ts +++ b/packages/graphql-codegen-cli/src/generate-and-save.ts @@ -167,7 +167,9 @@ function isConfiguredOutput(output: any): output is Types.ConfiguredOutput { async function hashFile(filePath: string): Promise { try { - return hash(await readFile(filePath)); + const fileContent = await readFile(filePath); + fileContent.replace(/\r\n/g, '\n'); + return hash(fileContent); } catch (err) { if (err && err.code === 'ENOENT') { // return null if file does not exist From 2cacfbb956012f0df94008f4636b6c03ccca15b4 Mon Sep 17 00:00:00 2001 From: Eddy Nguyen Date: Mon, 14 Apr 2025 23:16:34 +1000 Subject: [PATCH 2/2] Add changeset --- .changeset/weak-carrots-grin.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/weak-carrots-grin.md diff --git a/.changeset/weak-carrots-grin.md b/.changeset/weak-carrots-grin.md new file mode 100644 index 00000000000..78240e6cbda --- /dev/null +++ b/.changeset/weak-carrots-grin.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/cli': patch +--- + +Treat windows and unix line ending the same when using --check flag