From 7672c88565ca37649327c03f6daf1314bfaba68e Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Sun, 7 Jan 2024 09:42:48 -0800 Subject: [PATCH] Make api path if it doesn't exist --- packages/website/scripts/generateModulePages.mts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/website/scripts/generateModulePages.mts b/packages/website/scripts/generateModulePages.mts index c2870d3a44..041df52735 100644 --- a/packages/website/scripts/generateModulePages.mts +++ b/packages/website/scripts/generateModulePages.mts @@ -6,7 +6,12 @@ import { FnDocumentation } from "@quri/squiggle-lang"; import { ModulePage, modulePages } from "../templates.mjs"; import { generateModuleContent } from "./generateModuleContent.mjs"; -const targetFilename = (name: string) => `./src/pages/docs/Api/${name}.mdx`; +const directoryPath = `./src/pages/docs/Api`; +if (!fs.existsSync(directoryPath)) { + fs.mkdirSync(directoryPath, { recursive: true }); +} + +const targetFilename = (name: string) => `${directoryPath}/${name}.mdx`; //We need to escape the curly braces in the markdown for .jsx files. function escapedStr(str: string) { @@ -50,7 +55,7 @@ const generateMetaPage = async ({ pages }: { pages: ModulePage[] }) => { } const names = pages.map((p) => p.name); - const fileName = `./src/pages/docs/Api/_meta.json`; + const fileName = `${directoryPath}/_meta.json`; const content = JSON.stringify(convertToKeyValuePairs(names), null, 2); fs.writeFile(fileName, content, (err) => {