Describe the bug
Cannot run graphql-codegen init due to an error on Windows 10.
To Reproduce
Steps to reproduce the behavior:
yarn global add @graphql-codegen/cligraphql-codegen initExpected behavior
The command to execute correctly ...
Environment:
@graphql-codegen/...: graphql-codegen/cliAdditional context
Error with powershell:
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:5 char:13
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+ ~
Unexpected token ')' in expression or statement.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:8 char:3
+ if [ -x "$basedir/pwsh" ]; then
+ ~
Missing '(' after 'if' in if statement.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:8 char:5
+ if [ -x "$basedir/pwsh" ]; then
+ ~
Missing type name after '['.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:9 char:20
+ ... edir/pwsh" "$basedir/../Data/global/node_modules/.bin/graphql-codege ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"$basedir/../Data/global/node_modules/.bin/graphql-codegen.ps1"' in expression or statement.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:9 char:84
+ ... "$basedir/../Data/global/node_modules/.bin/graphql-codegen.ps1" "$@"
+ ~~~~
Unexpected token '"$@"' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
Error with powershell core 6:
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:4 char:6
+ case `uname` in
+ ~~
The Unicode escape sequence is not valid. A valid sequence is `u{ followed by one to six hex digits and a closing '}'.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:5 char:13
+ *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
+ ~
Unexpected token ')' in expression or statement.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:8 char:3
+ if [ -x "$basedir/pwsh" ]; then
+ ~
Missing '(' after 'if' in if statement.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:8 char:5
+ if [ -x "$basedir/pwsh" ]; then
+ ~
Missing type name after '['.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:9 char:20
+ ... edir/pwsh" "$basedir/../Data/global/node_modules/.bin/graphql-codege ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '"$basedir/../Data/global/node_modules/.bin/graphql-codegen.ps1"' in expression or statement.
At C:\Users\adrie\AppData\Local\Yarn\bin\graphql-codegen.ps1:9 char:84
+ ... "$basedir/../Data/global/node_modules/.bin/graphql-codegen.ps1" "$@"
+ ~~~~
Unexpected token '"$@"' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : InvalidUnicodeEscapeSequence
I found a "workaround". By using graphql-codegen.cmd init it works (using the cmd script instead of the ps1 script).
@pellea the .ps script is created by Yarn, so I'm not sure it's related to the codegen (maybe we missed something?).
Anyway, I don't have Windows environment, so it might be difficult for me for to fix that soon :(
@pellea It seems like there are some issue with Yarn and PowerShell.
Can you please try to take a look at this issue?
https://github.com/yarnpkg/yarn/issues/6902
I think they already solved it in the latest version.
The graphql-codegen init command is working with Yarn 1.15.2. Thx for pointing out the other issue.
I'd recommend using WSL to avoid issues like this.