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 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