refactor: replace Bun APIs with Node.js equivalents

Replace Bun.argv with process.argv, Bun.file() with fs/promises,
Bun.stringWidth with string-width package, and Bun.wrapAnsi with
wrap-ansi package for better compatibility.
This commit is contained in:
mitchell 2026-05-25 23:13:16 -04:00
parent b212fee200
commit 0c71e2cd54
7 changed files with 39 additions and 18 deletions

View file

@ -1,9 +1,10 @@
import fs from "node:fs/promises";
import os from "node:os";
import { autocomplete, intro, isCancel, outro, text } from "@clack/prompts";
import chalk from "chalk";
const home = os.homedir();
const configFile = Bun.file(`${home}/.lmc_config.json`);
const configPath = `${home}/.lmc_config.json`;
export interface AppConfig {
baseURL: string;
@ -36,7 +37,7 @@ export async function initConfig(old: AppConfig | null): Promise<AppConfig> {
const config = { baseURL, model } satisfies AppConfig;
await configFile.write(JSON.stringify(config, null, " "));
await fs.writeFile(configPath, JSON.stringify(config, null, " "));
outro(chalk.green("Configuration saved!"));
@ -63,10 +64,11 @@ export async function loadConfig(
): Promise<AppConfig | null> {
let config: AppConfig;
try {
config = await configFile.json();
const text = await fs.readFile(configPath);
config = JSON.parse(text.toString("utf8"));
} catch {
if (configFlag) return null;
console.error(`Config not found at ${configFile.name}`);
console.error(`Config not found at ${configPath}`);
return null;
}