Skip to content

CLI's --check option should not fail due to differences in line endings #10309

@tiagojufr

Description

@tiagojufr

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

  1. Run graphql-codegen on any project
  2. Change the line ending on a generated file from LF to CRLF
  3. 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
  • graphql version: 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions