You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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