2026-02-17 13:39:47 -06:00
|
|
|
import fs from "node:fs";
|
2026-03-03 08:45:26 -06:00
|
|
|
import { paperclipConfigSchema, type PaperclipConfig } from "@paperclipai/shared";
|
2026-02-18 16:46:45 -06:00
|
|
|
import { resolvePaperclipConfigPath } from "./paths.js";
|
2026-02-17 13:39:47 -06:00
|
|
|
|
|
|
|
|
export function readConfigFile(): PaperclipConfig | null {
|
2026-02-18 16:46:45 -06:00
|
|
|
const configPath = resolvePaperclipConfigPath();
|
2026-02-17 13:39:47 -06:00
|
|
|
|
|
|
|
|
if (!fs.existsSync(configPath)) return null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const raw = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
|
|
|
return paperclipConfigSchema.parse(raw);
|
|
|
|
|
} catch {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|