gitguide
Version:
AI-powered README generator for any project directory
35 lines • 1.32 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = getConfig;
exports.saveConfig = saveConfig;
exports.checkApiKey = checkApiKey;
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
const os_1 = __importDefault(require("os"));
const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.gitguide');
const CONFIG_FILE = path_1.default.join(CONFIG_DIR, 'config.json');
async function getConfig() {
try {
await fs_extra_1.default.ensureDir(CONFIG_DIR);
if (await fs_extra_1.default.pathExists(CONFIG_FILE)) {
const content = await fs_extra_1.default.readFile(CONFIG_FILE, 'utf8');
return JSON.parse(content);
}
}
catch (error) {
// Ignore errors, return empty config
}
return {};
}
async function saveConfig(config) {
await fs_extra_1.default.ensureDir(CONFIG_DIR);
await fs_extra_1.default.writeFile(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf8');
}
async function checkApiKey() {
const config = await getConfig();
return !!config.apiKey;
}
//# sourceMappingURL=config.js.map