@cwdpk/cocommit
Version:
AI-powered git commit message generator CLI tool (CoCommit)
30 lines • 1.1 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfigFilePath = getConfigFilePath;
exports.saveAIConfig = saveAIConfig;
exports.loadAIConfig = loadAIConfig;
const promises_1 = __importDefault(require("fs/promises"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const CONFIG_FILENAME = ".cocommit-config.json";
function getConfigFilePath() {
return path_1.default.join(os_1.default.homedir(), CONFIG_FILENAME);
}
async function saveAIConfig(config) {
const filePath = getConfigFilePath();
await promises_1.default.writeFile(filePath, JSON.stringify(config, null, 2), { flag: "w" });
}
async function loadAIConfig() {
const filePath = getConfigFilePath();
try {
const data = await promises_1.default.readFile(filePath, "utf-8");
return JSON.parse(data);
}
catch (err) {
return null;
}
}
//# sourceMappingURL=config.js.map