Upload files to "src/utils"

This commit is contained in:
2026-07-03 00:11:04 +00:00
parent 0c19e8ff9e
commit 794cfb96d4
3 changed files with 157 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { $ } from "bun";
export interface ShellResult {
success: boolean;
exitCode: number;
stdout: string;
stderr: string;
}
export async function run(
parts: TemplateStringsArray,
...values: string[]
): Promise<ShellResult> {
const escaped = values.map((v) => $.escape(v));
let command = parts[0] ?? "";
for (let i = 0; i < escaped.length; i++) {
command += escaped[i] + (parts[i + 1] ?? "");
}
const result = await $`${{ raw: command }}`.nothrow().quiet();
return {
success: result.exitCode === 0,
exitCode: result.exitCode,
stdout: result.stdout.toString(),
stderr: result.stderr.toString(),
};
}