@@ -3,6 +3,7 @@ import { BunProc } from "../bun"
33import { Instance } from "../project/instance"
44import { Filesystem } from "../util/filesystem"
55import { Process } from "../util/process"
6+ import { which } from "../util/which"
67import { Flag } from "@/flag/flag"
78
89export interface Info {
@@ -18,7 +19,7 @@ export const gofmt: Info = {
1819 command : [ "gofmt" , "-w" , "$FILE" ] ,
1920 extensions : [ ".go" ] ,
2021 async enabled ( ) {
21- return Bun . which ( "gofmt" ) !== null
22+ return which ( "gofmt" ) !== null
2223 } ,
2324}
2425
@@ -27,7 +28,7 @@ export const mix: Info = {
2728 command : [ "mix" , "format" , "$FILE" ] ,
2829 extensions : [ ".ex" , ".exs" , ".eex" , ".heex" , ".leex" , ".neex" , ".sface" ] ,
2930 async enabled ( ) {
30- return Bun . which ( "mix" ) !== null
31+ return which ( "mix" ) !== null
3132 } ,
3233}
3334
@@ -152,7 +153,7 @@ export const zig: Info = {
152153 command : [ "zig" , "fmt" , "$FILE" ] ,
153154 extensions : [ ".zig" , ".zon" ] ,
154155 async enabled ( ) {
155- return Bun . which ( "zig" ) !== null
156+ return which ( "zig" ) !== null
156157 } ,
157158}
158159
@@ -171,7 +172,7 @@ export const ktlint: Info = {
171172 command : [ "ktlint" , "-F" , "$FILE" ] ,
172173 extensions : [ ".kt" , ".kts" ] ,
173174 async enabled ( ) {
174- return Bun . which ( "ktlint" ) !== null
175+ return which ( "ktlint" ) !== null
175176 } ,
176177}
177178
@@ -180,7 +181,7 @@ export const ruff: Info = {
180181 command : [ "ruff" , "format" , "$FILE" ] ,
181182 extensions : [ ".py" , ".pyi" ] ,
182183 async enabled ( ) {
183- if ( ! Bun . which ( "ruff" ) ) return false
184+ if ( ! which ( "ruff" ) ) return false
184185 const configs = [ "pyproject.toml" , "ruff.toml" , ".ruff.toml" ]
185186 for ( const config of configs ) {
186187 const found = await Filesystem . findUp ( config , Instance . directory , Instance . worktree )
@@ -210,7 +211,7 @@ export const rlang: Info = {
210211 command : [ "air" , "format" , "$FILE" ] ,
211212 extensions : [ ".R" ] ,
212213 async enabled ( ) {
213- const airPath = Bun . which ( "air" )
214+ const airPath = which ( "air" )
214215 if ( airPath == null ) return false
215216
216217 try {
@@ -239,7 +240,7 @@ export const uvformat: Info = {
239240 extensions : [ ".py" , ".pyi" ] ,
240241 async enabled ( ) {
241242 if ( await ruff . enabled ( ) ) return false
242- if ( Bun . which ( "uv" ) !== null ) {
243+ if ( which ( "uv" ) !== null ) {
243244 const proc = Process . spawn ( [ "uv" , "format" , "--help" ] , { stderr : "pipe" , stdout : "pipe" } )
244245 const code = await proc . exited
245246 return code === 0
@@ -253,7 +254,7 @@ export const rubocop: Info = {
253254 command : [ "rubocop" , "--autocorrect" , "$FILE" ] ,
254255 extensions : [ ".rb" , ".rake" , ".gemspec" , ".ru" ] ,
255256 async enabled ( ) {
256- return Bun . which ( "rubocop" ) !== null
257+ return which ( "rubocop" ) !== null
257258 } ,
258259}
259260
@@ -262,7 +263,7 @@ export const standardrb: Info = {
262263 command : [ "standardrb" , "--fix" , "$FILE" ] ,
263264 extensions : [ ".rb" , ".rake" , ".gemspec" , ".ru" ] ,
264265 async enabled ( ) {
265- return Bun . which ( "standardrb" ) !== null
266+ return which ( "standardrb" ) !== null
266267 } ,
267268}
268269
@@ -271,7 +272,7 @@ export const htmlbeautifier: Info = {
271272 command : [ "htmlbeautifier" , "$FILE" ] ,
272273 extensions : [ ".erb" , ".html.erb" ] ,
273274 async enabled ( ) {
274- return Bun . which ( "htmlbeautifier" ) !== null
275+ return which ( "htmlbeautifier" ) !== null
275276 } ,
276277}
277278
@@ -280,7 +281,7 @@ export const dart: Info = {
280281 command : [ "dart" , "format" , "$FILE" ] ,
281282 extensions : [ ".dart" ] ,
282283 async enabled ( ) {
283- return Bun . which ( "dart" ) !== null
284+ return which ( "dart" ) !== null
284285 } ,
285286}
286287
@@ -289,7 +290,7 @@ export const ocamlformat: Info = {
289290 command : [ "ocamlformat" , "-i" , "$FILE" ] ,
290291 extensions : [ ".ml" , ".mli" ] ,
291292 async enabled ( ) {
292- if ( ! Bun . which ( "ocamlformat" ) ) return false
293+ if ( ! which ( "ocamlformat" ) ) return false
293294 const items = await Filesystem . findUp ( ".ocamlformat" , Instance . directory , Instance . worktree )
294295 return items . length > 0
295296 } ,
@@ -300,7 +301,7 @@ export const terraform: Info = {
300301 command : [ "terraform" , "fmt" , "$FILE" ] ,
301302 extensions : [ ".tf" , ".tfvars" ] ,
302303 async enabled ( ) {
303- return Bun . which ( "terraform" ) !== null
304+ return which ( "terraform" ) !== null
304305 } ,
305306}
306307
@@ -309,7 +310,7 @@ export const latexindent: Info = {
309310 command : [ "latexindent" , "-w" , "-s" , "$FILE" ] ,
310311 extensions : [ ".tex" ] ,
311312 async enabled ( ) {
312- return Bun . which ( "latexindent" ) !== null
313+ return which ( "latexindent" ) !== null
313314 } ,
314315}
315316
@@ -318,7 +319,7 @@ export const gleam: Info = {
318319 command : [ "gleam" , "format" , "$FILE" ] ,
319320 extensions : [ ".gleam" ] ,
320321 async enabled ( ) {
321- return Bun . which ( "gleam" ) !== null
322+ return which ( "gleam" ) !== null
322323 } ,
323324}
324325
@@ -327,7 +328,7 @@ export const shfmt: Info = {
327328 command : [ "shfmt" , "-w" , "$FILE" ] ,
328329 extensions : [ ".sh" , ".bash" ] ,
329330 async enabled ( ) {
330- return Bun . which ( "shfmt" ) !== null
331+ return which ( "shfmt" ) !== null
331332 } ,
332333}
333334
@@ -336,7 +337,7 @@ export const nixfmt: Info = {
336337 command : [ "nixfmt" , "$FILE" ] ,
337338 extensions : [ ".nix" ] ,
338339 async enabled ( ) {
339- return Bun . which ( "nixfmt" ) !== null
340+ return which ( "nixfmt" ) !== null
340341 } ,
341342}
342343
@@ -345,7 +346,7 @@ export const rustfmt: Info = {
345346 command : [ "rustfmt" , "$FILE" ] ,
346347 extensions : [ ".rs" ] ,
347348 async enabled ( ) {
348- return Bun . which ( "rustfmt" ) !== null
349+ return which ( "rustfmt" ) !== null
349350 } ,
350351}
351352
@@ -372,7 +373,7 @@ export const ormolu: Info = {
372373 command : [ "ormolu" , "-i" , "$FILE" ] ,
373374 extensions : [ ".hs" ] ,
374375 async enabled ( ) {
375- return Bun . which ( "ormolu" ) !== null
376+ return which ( "ormolu" ) !== null
376377 } ,
377378}
378379
@@ -381,7 +382,7 @@ export const cljfmt: Info = {
381382 command : [ "cljfmt" , "fix" , "--quiet" , "$FILE" ] ,
382383 extensions : [ ".clj" , ".cljs" , ".cljc" , ".edn" ] ,
383384 async enabled ( ) {
384- return Bun . which ( "cljfmt" ) !== null
385+ return which ( "cljfmt" ) !== null
385386 } ,
386387}
387388
@@ -390,6 +391,6 @@ export const dfmt: Info = {
390391 command : [ "dfmt" , "-i" , "$FILE" ] ,
391392 extensions : [ ".d" ] ,
392393 async enabled ( ) {
393- return Bun . which ( "dfmt" ) !== null
394+ return which ( "dfmt" ) !== null
394395 } ,
395396}
0 commit comments