CLI's `--check` option should not fail due to differences in line endings
Which packages are impacted by your issue?
@graphql-codegen/cli
Describe the bug
This is the behavior I see in my Windows 11 machine. Not sure if the same applies to other OS.
graphql-codegen generates files with LF line endings. If something changes that file from LF to CRLF (e.g. git commit and checkout), then graphql-codegen --check will fail, saying the file is stale.
The file content is exactly the same (if we only look at the generated code), so I believe this library should be line ending agnostic and compare the actual code.
I'm not providing a repro as from what I know we can't change line endings in online code editors...
Your Example Website or App
some proprietary app
Steps to Reproduce the Bug or Issue
- Run
graphql-codegenon any project - Change the line ending on a generated file from LF to CRLF
- Run
graphql-codegen --check
Expected behavior
I expect that graphql-codegen --check would not fail just because the file has different line endings.
Screenshots or Videos
No response
Platform
- OS: Windows
- NodeJS: 22.12.0
graphqlversion: 16.10.0@graphql-codegen/*version(s): 5.0.5
Codegen Config File
codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: './src/gql/**/typeDefs.ts',
generates: {
'./src/types/__generated__/types.ts': {
plugins: ['typescript', 'typescript-resolvers'],
},
},
};
export default config;
Additional context
No response
Hi @tiagojufr ,
I've released an alpha version:
@graphql-codegen/cli@5.0.6-alpha-20250414132312-2cacfbb956012f0df94008f4636b6c03ccca15b4
Could you please try and let me know if it fixes your issue?
Hi @eddeee888,
Tried it out but unfortunately the issue persists.