dotansimha / dotansimha/graphql-code-generator
`afterAllFileWrite` hook fails on Windows when near-operation-file preset is used
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Which packages are impacted by your issue?
@graphql-codegen/cli
### Describe the bug
When using `afterAllFileWrite` hook with prettier or etc. in Windows, the invalid file path is passed to the tool and causing error.
### Your Example Website or App
https://github.com/jet2jet/graphql-code-generator-issue-hooks-failed-on-windows
### Steps to Reproduce the Bug or Issue
1. Checkout the example repository
2. Run `npm run codegen` in Windows (not in WSL)
### Expected behavior
No error has occurred (prettier success)
### Screenshots or Videos
Output is below:
```
F:\Test\gql-codegen-test\graphql-code-generator-issue-hooks-failed-on-windows>npm run codegen
> graphql-codegen-issue-template@1.0.0 codegen
> graphql-codegen --config ./codegen.ts
✔ Parse Configuration
✔ Generate outputs
Error: Command failed: prettier --write types.ts F\:/Test/gql-codegen-test/graphql-code-generator-issue-hooks-failed-on-windows/document.generated.ts
[error] No files matching the pattern were found: "F\:/Test/gql-codegen-test/graphql-code-generator-issue-hooks-failed-on-windows/document.generated.ts".
at ChildProcess.exithandler (child_process.js:383:12)
at ChildProcess.emit (events.js:400:28)
at ChildProcess.emit (domain.js:475:12)
at maybeClose (internal/child_process.js:1058:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) {
killed: false,
code: 2,
signal: null,
cmd: 'prettier --write types.ts F\\:/Test/gql-codegen-test/graphql-code-generator-issue-hooks-failed-on-windows/document.generated.ts'
}
```
### Platform
- OS: Windows
- NodeJS: 14.18.2
- `graphql` version: 16.2.0
- `@graphql-codegen/*` version(s): 2.13.7
### Codegen Config File
(see the repository)
### Additional context
When the file path includes spaces, the argument passed to prettier is enclosed with single quotations, which are invalid in Windows.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.