英文:
How to automatically run Laravel Pint on file save in VSCode?
问题
Laravel Pint文档 指定您可以通过调用位于 vendor/bin 目录中的二进制文件来运行 Pint,如下所示:
./vendor/bin/pint
我想在VSCode中设置这样的功能,以便在保存特定文件时自动运行 Pint。我该如何实现这一目标?
英文:
The Laravel Pint docs specifies that you can run Pint by invoking the binary located in the vendor/bin directory like this:
./vendor/bin/pint
I would like to set this up in VSCode so that it automatically runs Pint when a specific file is saved. How can I achieve this?
答案1
得分: 3
一个可能的解决方案是使用一个允许你在文件保存时运行命令的扩展:
例如,你可以使用 Run on Save 扩展,然后在 settings.json
中(最好是本地的),添加以下命令:
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.php$",
"cmd": "${workspaceFolder}/vendor/bin/pint ${file}"
}
]
}
这将仅在保存特定文件时调用 Pint。
英文:
One possible solution is to use an extension that let's you run commands on file saves:
For example, you can use the Run on Save extension, then in the settings.json
(preferably the local one), add the following command:
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.php$",
"cmd": "${workspaceFolder}/vendor/bin/pint ${file}"
}
]
}
This should invoke Pint only on the specific file that was saved.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论