From d19ae90e6ccdd6b68a9002e8475e138eae25226a Mon Sep 17 00:00:00 2001 From: Justin Spahr-Summers Date: Mon, 18 Nov 2024 14:30:00 +0000 Subject: [PATCH] Error if destination already exists --- src/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.ts b/src/index.ts index 0d47001..8cc1ef9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,6 +38,17 @@ async function createServer(directory: string, options: any = {}) { const spinner = ora("Creating MCP server...").start(); try { + // Check if directory already exists + try { + await fs.access(directory); + spinner.fail( + chalk.red(`Error: Directory '${directory}' already exists.`), + ); + process.exit(1); + } catch (err) { + // Directory doesn't exist, we can proceed + } + // Create project directory await fs.mkdir(directory, { recursive: true });