Replies: 1 comment 3 replies
-
What not changing this behavior instead. dprint takes a file, get the content, pass it to the tool, get the output and write back to the file. It will solve both Twig-Cs-Fixer and PHP-Cs-Fixer issues. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We're currently using https://dprint.dev/ as a formatter.
By using plugins it's able to format a lot of different file types. Based on the file extension it's deciding which formatter to use. This has the advantage that we just need to call one command and every supported file in the whole project is formatted. Also in the IDE we just need to configure one command which is called for format-on-save.
Usually dprint passes the contents via stdin, reads the formatted result from stdout and writes that back to the file.
For Twig files we configured https://github.com/dprint/dprint-plugin-exec/ to call Twig-CS-Fixer. But we need to have a wrapper script which writes the stdin to a temporary file, let Twig-CS-Fixer do the formatting, read the file and print it to stdout. First we used Twig-CS-Fixer to directly write to the file, but then the file is written twice which caused issues for the colleague using VS Code.
You can see the wrapper script implementation at dprint/dprint-plugin-exec#26 (comment)
It would be much better (probably faster and definitely easier on the SSD) to be able to use PHP-CS-Fixer via stdin and get the result via stdout.
Additional References:
Beta Was this translation helpful? Give feedback.
All reactions