Просмотр исходного кода

feat: add shfmt formatter for shell scripts (#6204)

ja 1 месяц назад
Родитель
Сommit
b0e4408ecf

+ 9 - 0
packages/opencode/src/format/formatter.ts

@@ -313,3 +313,12 @@ export const gleam: Info = {
     return Bun.which("gleam") !== null
   },
 }
+
+export const shfmt: Info = {
+  name: "shfmt",
+  command: ["shfmt", "-w", "$FILE"],
+  extensions: [".sh", ".bash"],
+  async enabled() {
+    return Bun.which("shfmt") !== null
+  },
+}

+ 1 - 0
packages/web/src/content/docs/formatters.mdx

@@ -30,6 +30,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
 | ocamlformat          | .ml, .mli                                                                                                | `ocamlformat` command available and `.ocamlformat` config file                                        |
 | terraform            | .tf, .tfvars                                                                                             | `terraform` command available                                                                         |
 | gleam                | .gleam                                                                                                   | `gleam` command available                                                                             |
+| shfmt                | .sh, .bash                                                                                               | `shfmt` command available                                                                             |
 | oxfmt (Experimental) | .js, .jsx, .ts, .tsx                                                                                     | `oxfmt` dependency in `package.json` and an [experimental env variable flag](/docs/cli/#experimental) |
 
 So if your project has `prettier` in your `package.json`, OpenCode will automatically use it.