Skip to content

Commit

Permalink
getProjectPath also ensure root exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHallen122 committed Dec 16, 2024
1 parent 8b3c703 commit b4c0ff8
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ export async function saveGeneratedCode(
content: string,
): Promise<string> {
try {
// Ensure the root directory exists
const rootDir = getRootDir();
if (!rootDir) {
throw new Error('Root directory is undefined.');
}
await fs.mkdir(rootDir, { recursive: true });

// Ensure the projects directory exists
const projectsDir = getProjectsDir();
if (!projectsDir) {
throw new Error('Projects directory is undefined.');
}
await fs.mkdir(projectsDir, { recursive: true });

// Generate a unique UUID for the project folder
const projectUUID = uuidv4();

Expand All @@ -50,7 +36,8 @@ export async function saveGeneratedCode(

// Write the content to the file
await fs.writeFile(filePath, content, 'utf8');
return filePath;

return projectPath;
} catch (error) {
console.error('Error saving generated code:', error);
throw error;
Expand Down

0 comments on commit b4c0ff8

Please sign in to comment.