29 lines
599 B
TypeScript
29 lines
599 B
TypeScript
import { join } from "path"
|
|
|
|
export interface VmConfig {
|
|
cpus?: number
|
|
memory?: string
|
|
image?: string
|
|
mounts?: Record<string, string>
|
|
}
|
|
|
|
export interface SandlotConfig {
|
|
vm?: VmConfig
|
|
}
|
|
|
|
const DEFAULT_CONFIG: SandlotConfig = {
|
|
vm: { image: "ubuntu:24.04" },
|
|
}
|
|
|
|
export async function loadConfig(repoRoot: string): Promise<SandlotConfig> {
|
|
const path = join(repoRoot, "sandlot.json")
|
|
const file = Bun.file(path)
|
|
if (await file.exists()) {
|
|
const userConfig = await file.json()
|
|
return {
|
|
vm: { ...DEFAULT_CONFIG.vm, ...userConfig.vm },
|
|
}
|
|
}
|
|
return DEFAULT_CONFIG
|
|
}
|