UNPKG

bgipfs

Version:
14 lines (13 loc) 502 B
import { readFile } from 'node:fs/promises'; import { join } from 'node:path'; export const CONFIG_FILENAME = 'ipfs-upload.config.json'; export async function readConfig(configPath) { try { const targetPath = configPath || join(process.cwd(), CONFIG_FILENAME); const configContent = await readFile(targetPath, 'utf8'); return JSON.parse(configContent); } catch { throw new Error('Failed to read config file. Run "bgipfs upload config init" first.'); } }