Skip to content

Commit

Permalink
GO-5100: Throw error for multiple markdown files in export folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jmetrikat committed Feb 11, 2025
1 parent cd0da85 commit b1a43f1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api/getExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export async function getExport(spaceId: string, objectId: string, format: strin

// Find markdown file in the output directory
const outputPath = response.path;
const mdFile = fs.readdirSync(outputPath).find((file) => file.endsWith(".md"));
if (!mdFile) throw new Error("Markdown file not found");
const mdFiles = fs.readdirSync(outputPath).filter((file) => file.endsWith(".md"));
if (mdFiles.length === 0) throw new Error("Markdown file not found in export .");
if (mdFiles.length > 1) throw new Error("Multiple markdown files found in export.");
const mdFile = mdFiles[0];

// Read markdown file and replace relative image paths with absolute paths
const markdown = fs.readFileSync(path.join(outputPath, mdFile), "utf8");
Expand Down

0 comments on commit b1a43f1

Please sign in to comment.