Skip to content

Commit

Permalink
Check if the outputDir exists before attempting to create the version…
Browse files Browse the repository at this point in the history
…s.json file (#892)
  • Loading branch information
tyler-mairose-sp authored and sserrata committed Jul 23, 2024
1 parent 0c67e99 commit 14769a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/docusaurus-plugin-openapi-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,18 @@ custom_edit_url: null
});
}

if (!fs.existsSync(outputDir)) {
try {
fs.mkdirSync(outputDir, { recursive: true });
console.log(chalk.green(`Successfully created "${outputDir}"`));
} catch (err) {
console.error(
chalk.red(`Failed to create "${outputDir}"`),
chalk.yellow(err)
);
}
}

const versionsJson = JSON.stringify(versionsArray, null, 2);
try {
fs.writeFileSync(`${outputDir}/versions.json`, versionsJson, "utf8");
Expand Down

0 comments on commit 14769a4

Please sign in to comment.