UNPKG

difflytic

Version:

AI-powered code review for GitLab/GitHub MRs using OpenAI and more.

38 lines (37 loc) 1.39 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Config = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); class Config { static loadConfigFile() { if (Object.keys(this.configCache).length > 0) return this.configCache; const configFiles = ['.difflyticrc.json', 'config.json']; for (const file of configFiles) { const filePath = path_1.default.resolve(process.cwd(), file); if (fs_1.default.existsSync(filePath)) { try { const content = fs_1.default.readFileSync(filePath, 'utf-8'); this.configCache = JSON.parse(content); return this.configCache; } catch (err) { console.error(`Failed to parse config file ${file}:`, err); } } } this.configCache = {}; return this.configCache; } static get(key, defaultValue) { const config = this.loadConfigFile(); return config[key] || process.env[key] || defaultValue; } } exports.Config = Config; Config.configCache = {}; exports.default = Config;