From 2b787039b6755c80a38ff6a3c04a1d7628c10c3c Mon Sep 17 00:00:00 2001 From: Joseph Martinez Date: Thu, 27 Jun 2024 14:22:06 -0400 Subject: [PATCH] Add error handling to check if current repo has .git --- src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index a4d3552..b8ea4f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,13 +8,15 @@ import { getOpenAIResponse, getAnthropicResponse, getOllamaResponse, estimateCos import { createLoadingIndicator, generateFileName } from './cliUtils'; export async function runMktute() { + // Check if git logs + if (!(fs.readdirSync(process.cwd()).includes('.git'))) { + throw new Error("To use mktute, initialize a git repo in the current working directory.") + } + // Select commits const { startCommit, endCommit } = await selectCommits(); const diffsAndContent = await getDiffsAndContent(startCommit, endCommit); - // Drop git diffs into local file for debugging - // fs.writeFileSync("./diffsAndContent.md", diffsAndContent); - // Enter tutorial topic const {topic} = await inquirer.prompt({ type: 'input',