Skip to content

Commit

Permalink
Merge pull request storybookjs#29371 from storybookjs/fix-29358
Browse files Browse the repository at this point in the history
Core: Fix building Storybook deleting project root files
  • Loading branch information
JReinhold authored Oct 16, 2024
2 parents f0af3e0 + ceb32c2 commit 921c971
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions code/core/src/core-server/build-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,8 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption
if (options.outputDir === '/') {
throw new Error("Won't remove directory '/'. Check your outputDir!");
}

try {
const outputDirFiles = await readdir(options.outputDir);
for (const file of outputDirFiles) {
await rm(file, { recursive: true, force: true });
}
} catch {
await mkdir(options.outputDir, { recursive: true });
}

if (!existsSync(options.outputDir)) {
await mkdir(options.outputDir, { recursive: true });
} else if ((await readdir(options.outputDir)).length > 0) {
await rm(options.outputDir, { recursive: true, force: true });
await mkdir(options.outputDir, { recursive: true });
}
await rm(options.outputDir, { recursive: true, force: true }).catch(() => {});
await mkdir(options.outputDir, { recursive: true });

const config = await loadMainConfig(options);
const { framework } = config;
Expand Down

0 comments on commit 921c971

Please sign in to comment.