refactor: migrate Bun.spawn to Process utility with timeout and cleanup (#14448)

This commit is contained in:
Dax
2026-02-24 23:04:15 -05:00
committed by GitHub
parent da40ab7b3d
commit 814c1d398c
13 changed files with 203 additions and 114 deletions

View File

@@ -1,7 +1,8 @@
import { readableStreamToText } from "bun"
import { text } from "node:stream/consumers"
import { BunProc } from "../bun"
import { Instance } from "../project/instance"
import { Filesystem } from "../util/filesystem"
import { Process } from "../util/process"
import { Flag } from "@/flag/flag"
export interface Info {
@@ -213,12 +214,13 @@ export const rlang: Info = {
if (airPath == null) return false
try {
const proc = Bun.spawn(["air", "--help"], {
const proc = Process.spawn(["air", "--help"], {
stdout: "pipe",
stderr: "pipe",
})
await proc.exited
const output = await readableStreamToText(proc.stdout)
if (!proc.stdout) return false
const output = await text(proc.stdout)
// Check for "Air: An R language server and formatter"
const firstLine = output.split("\n")[0]
@@ -238,7 +240,7 @@ export const uvformat: Info = {
async enabled() {
if (await ruff.enabled()) return false
if (Bun.which("uv") !== null) {
const proc = Bun.spawn(["uv", "format", "--help"], { stderr: "pipe", stdout: "pipe" })
const proc = Process.spawn(["uv", "format", "--help"], { stderr: "pipe", stdout: "pipe" })
const code = await proc.exited
return code === 0
}