Check for directory existence _before_ asking questions
This commit is contained in:
parent
4622992557
commit
5bf1bdc6ac
1 changed files with 9 additions and 11 deletions
20
src/index.ts
20
src/index.ts
|
|
@ -59,6 +59,15 @@ async function updateClaudeConfig(directory: string, name: string) {
|
|||
}
|
||||
|
||||
async function createServer(directory: string, options: any = {}) {
|
||||
// Check if directory already exists
|
||||
try {
|
||||
await fs.access(directory);
|
||||
console.log(chalk.red(`Error: Directory '${directory}' already exists.`));
|
||||
process.exit(1);
|
||||
} catch (err) {
|
||||
// Directory doesn't exist, we can proceed
|
||||
}
|
||||
|
||||
const questions = [
|
||||
{
|
||||
type: "input",
|
||||
|
|
@ -93,17 +102,6 @@ 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 });
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue