import { homedir } from 'os'; import { join } from 'path'; import fsExtra from 'fs-extra'; import { NetdataConfig } from './config.type'; import chalk from 'chalk'; const { readJson, writeJson, pathExists } = fsExtra; const configPath = join(homedir(), '.netdatarc'); export const saveConfig = async (config: NetdataConfig) => { await writeJson(configPath, config, { spaces: 2 }); console.log(chalk.gray(`\nšŸ“ Saved config to ~/.netdatarc`)); }; export const loadConfig = async (): Promise => { if (await pathExists(configPath)) { return (await readJson(configPath)) as NetdataConfig; } return null; };