Save Runner for Visual Studio Code:提升开发效率的强大扩展
Save Runner for Visual Studio Code是一款功能强大的扩展工具,旨在为开发者提供在文件保存前后运行命令的能力。这款扩展受到了emeraldwalk.runonsave和eslint扩展的启发,旨在弥补eslint在保存时无法正确修复的问题。
主要功能:
配置示例:
interface Config extends vscode.WorkspaceConfiguration {
enabled: boolean; // 默认值为false
// 更新时显示输出面板
showOutput: boolean; // 默认值为false
// 在指定的shell下执行前/后命令。
shell: string; // 默认值为''
// 在运行命令前自动清除输出通道。
autoClearOutput: boolean;
// 要运行的命令
commands: Command[];
}
interface Command {
enabled?: boolean; // 默认值为false
/include?: string; // 匹配文件名的正则表达式
exclude?: string; // 排除文件名的正则表达式
// 保存前使用临时文件,将${tmpFile}传递给命令。
useTempFile?: boolean; // 默认值为true
// 异步运行保存后命令。
isAsync?: boolean; // 默认值为false
// 在文档保存前运行的命令,文档将被命令链的stdout替换。
// 如果useTempFile为false,文档将被管道到命令中。
pre: string | string[];
// 在文件成功保存到磁盘后运行的命令。
post: string | string[];
}
使用示例:
在保存前运行eslint_d --fix并更新文档:
"save-runner.enabled": true,
"save-runner.commands": [
// 将当前文档写入临时文件,运行eslint_d --fix,
// 然后对修改后的临时文件运行diff,并将其应用到文档中。
{
"enabled": false,
"include": "\\.[tj]sx?$",
"exclude": "/node_modules/",
"pre": "eslint_d --fix ${tmpFile}",
"post": "echo saved ${relname}"
},
// 将当前文档管道到goimports,
// 然后对goimports的输出运行diff并将其应用到文档中。
{
"enabled": true,
"include": "\\.go$",
"useTempFile": false,
"pre": "goimports",
"post": "echo saved ${relname}"
}
]
命令中的占位符:
未来计划:
相关链接:
许可证:
MIT
本站所有资源都是由网友投稿发布,或转载各大下载站, 请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则 产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:study_golang@163.com