-
Notifications
You must be signed in to change notification settings - Fork 391
Description
However, QUARTO_DOCUMENT_PATH does not output the same (using the absolute path for project and using a relative path for non-project)
I have looked into the difference between project render and singlefile render
Both start with render() which makes the input relative to Deno.cwd()
quarto-cli/src/command/render/cmd.ts
Lines 247 to 251 in a88e7cc
| renderResultInput = relative(Deno.cwd(), walk.path) || "."; | |
| if (renderResult) { | |
| renderResult.context.cleanup(); | |
| } | |
| renderResult = await render(renderResultInput, { |
However, when in a project, there will be some context compute which will end up normalizing (by adding back the Deno.cwd() like the following in renderProjects
quarto-cli/src/command/render/project.ts
Lines 287 to 294 in a88e7cc
| let projectRenderConfig = await computeProjectRenderConfig({ | |
| context, | |
| projType, | |
| projOutputDir, | |
| projDir, | |
| options: pOptions, | |
| files: pFiles, | |
| }); |
quarto-cli/src/command/render/project.ts
Lines 150 to 168 in a88e7cc
| // file normaliation | |
| const normalizeFiles = (targetFiles: string[]) => { | |
| return targetFiles.map((file) => { | |
| const target = isAbsolute(file) ? file : join(Deno.cwd(), file); | |
| if (!existsSync(target)) { | |
| throw new Error("Render target does not exist: " + file); | |
| } | |
| return normalizePath(target); | |
| }); | |
| }; | |
| if (inputs.files) { | |
| if (alwaysExecuteFiles) { | |
| alwaysExecuteFiles = normalizeFiles(alwaysExecuteFiles); | |
| inputs.files = normalizeFiles(inputs.files); | |
| } else if (inputs.options.useFreezer) { | |
| inputs.files = normalizeFiles(inputs.files); | |
| } | |
| } |
So basically,
-
When this is a project,
renderFilesis called with an absolute path
quarto-cli/src/command/render/project.ts
Lines 464 to 465 in a88e7cc
const fileResults = await renderFiles( projectRenderConfig.filesToRender, -
When not inside a project, so singleFile render,
renderFiles()is called with a relative path
quarto-cli/src/command/render/render-shared.ts
Lines 103 to 111 in a88e7cc
// otherwise it's just a file render const result = await renderFiles( [{ path }], options, nbContext, undefined, undefined, context, );
This is the different we see in those environment variable from this PR, as it will be inherited by target.source
quarto-cli/src/execute/environment.ts
Line 16 in a88e7cc
| Deno.env.set("QUARTO_DOCUMENT_PATH", dirname(options.target.source)); |
It seems there is room for improvement to make things work the same.
Originally posted by @cderv in #12271 (comment)