diff --git a/packages/mermaid/scripts/docs.mts b/packages/mermaid/scripts/docs.mts index 073a3c1a9..eaaa5a1f5 100644 --- a/packages/mermaid/scripts/docs.mts +++ b/packages/mermaid/scripts/docs.mts @@ -53,12 +53,13 @@ import mm from 'micromatch'; // @ts-ignore No typescript declaration file import flatmap from 'unist-util-flatmap'; import { visit } from 'unist-util-visit'; +import { fileURLToPath } from 'url'; // short-circuit `.schema.yaml` imports, so that we can safely import `shapes.js` register('./loadHook.mjs', import.meta.url); const { shapesDefs } = await import('../src/rendering-util/rendering-elements/shapes.js'); - -export const MERMAID_RELEASE_VERSION = JSON.parse(readFileSync('../mermaid/package.json', 'utf8')) +const packageJsonPath = join(fileURLToPath(import.meta.url), '../../package.json'); +export const MERMAID_RELEASE_VERSION = JSON.parse(readFileSync(packageJsonPath, 'utf8')) .version as string; const MERMAID_MAJOR_VERSION = MERMAID_RELEASE_VERSION.split('.')[0]; const CDN_URL = 'https://cdn.jsdelivr.net/npm'; // 'https://unpkg.com';