diff --git a/.changeset/forty-donkeys-care.md b/.changeset/forty-donkeys-care.md new file mode 100644 index 000000000..2bdc0bd8c --- /dev/null +++ b/.changeset/forty-donkeys-care.md @@ -0,0 +1,5 @@ +--- +'myst-cli': patch +--- + +Pass projectPath to loadFile whenever possible diff --git a/packages/myst-cli/src/build/meca/index.ts b/packages/myst-cli/src/build/meca/index.ts index 6d16481ac..52800030a 100644 --- a/packages/myst-cli/src/build/meca/index.ts +++ b/packages/myst-cli/src/build/meca/index.ts @@ -109,7 +109,7 @@ async function copyDependentFiles( ) { const cache = castSession(session); if (!cache.$getMdast(sourceFile)) { - await loadFile(session, sourceFile); + await loadFile(session, sourceFile, projectPath); } const pre = cache.$getMdast(sourceFile)?.pre; if (!pre) return; diff --git a/packages/myst-cli/src/build/utils/collectExportOptions.ts b/packages/myst-cli/src/build/utils/collectExportOptions.ts index d8aedd884..c3125094e 100644 --- a/packages/myst-cli/src/build/utils/collectExportOptions.ts +++ b/packages/myst-cli/src/build/utils/collectExportOptions.ts @@ -31,7 +31,7 @@ async function prepareExportOptions( if (projectPath && sourceFile === selectors.selectLocalConfigFile(state, projectPath)) { rawFrontmatter = selectors.selectLocalProjectConfig(state, projectPath); } else { - rawFrontmatter = await getRawFrontmatterFromFile(session, sourceFile); + rawFrontmatter = await getRawFrontmatterFromFile(session, sourceFile, projectPath); } let exportOptions = getExportListFromRawFrontmatter(session, formats, rawFrontmatter, sourceFile); // If no export options are provided in frontmatter, instantiate default options diff --git a/packages/myst-cli/src/frontmatter.ts b/packages/myst-cli/src/frontmatter.ts index 56bc4cc39..a99646f70 100644 --- a/packages/myst-cli/src/frontmatter.ts +++ b/packages/myst-cli/src/frontmatter.ts @@ -81,9 +81,13 @@ export function prepareToWrite(frontmatter: { license?: Licenses }) { return { ...frontmatter, license: licensesToString(frontmatter.license) }; } -export async function getRawFrontmatterFromFile(session: ISession, file: string) { +export async function getRawFrontmatterFromFile( + session: ISession, + file: string, + projectPath?: string, +) { const cache = castSession(session); - if (!cache.$getMdast(file)) await loadFile(session, file); + if (!cache.$getMdast(file)) await loadFile(session, file, projectPath); const result = cache.$getMdast(file); if (!result || !result.pre) return undefined; const vfile = new VFile();