Skip to content

Normalize file paths to absolute at execution engine entry point #14151

@cderv

Description

@cderv

fileExecutionEngineAndTarget in src/execute/engine.ts accepts both relative and absolute paths. This means cached ExecutionTarget.source can be either form depending on the caller, which has caused downstream bugs:

We could normalize file to absolute at the top of fileExecutionEngineAndTarget to establish an "always absolute" contract for target.source. This is the single convergence point for all callers (preview, render, format resolution).

export async function fileExecutionEngineAndTarget(
file: string,
flags: RenderFlags | undefined,
project: ProjectContext,
): Promise<{ engine: ExecutionEngineInstance; target: ExecutionTarget }> {
const cached = ensureFileInformationCache(project, file);
if (cached && cached.engine && cached.target) {
return { engine: cached.engine, target: cached.target };
}
// Get the launched engine
const engine = await fileExecutionEngine(file, flags, project);
if (!engine) {
throw new Error("Can't determine execution engine for " + file);
}
const markdown = await project.resolveFullMarkdownForFile(engine, file);
const target = await engine.target(file, flags?.quiet, markdown);
if (!target) {
throw new Error("Can't determine execution target for " + file);
}
// Cache the ExecutionEngineInstance
cached.engine = engine;
cached.target = target;
return { engine, target };
}

Just registering this idea to look into it when we are ready to make things more robust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions