Skip to content

Commit

Permalink
Ensure output created console message uses correct path
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonstyle committed Feb 4, 2021
1 parent 9878172 commit 604611c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/command/render/latekmk/latexmk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function quartoLatexmkOutputRecipe(
};

// run latexmk
await generatePdf(mkOptions);
const pdfOutput = await generatePdf(mkOptions);

// keep tex if requested
const compileTex = join(inputDir, output);
Expand All @@ -122,17 +122,14 @@ export function quartoLatexmkOutputRecipe(

// copy (or write for stdout) compiled pdf to final output location
if (finalOutput) {
const compilePdf = outputDir
? join(inputDir, outputDir, texStem + ".pdf")
: join(inputDir, texStem + ".pdf");
if (finalOutput === kStdOut) {
writeFileToStdout(compilePdf);
Deno.removeSync(compilePdf);
writeFileToStdout(pdfOutput);
Deno.removeSync(pdfOutput);
} else {
const outputPdf = expandPath(finalOutput);

if (normalize(compilePdf) !== normalize(outputPdf)) {
Deno.renameSync(compilePdf, outputPdf);
if (normalize(pdfOutput) !== normalize(outputPdf)) {
Deno.renameSync(pdfOutput, outputPdf);
}
}

Expand All @@ -148,7 +145,7 @@ export function quartoLatexmkOutputRecipe(

return finalOutput;
} else {
return texStem + ".pdf";
return pdfOutput;
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/command/render/latekmk/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
export const kLatexHeaderMessageOptions = { bold: true };
export const kLatexBodyMessageOptions = { indent: 2 };

export async function generatePdf(mkOptions: LatexmkOptions) {
export async function generatePdf(mkOptions: LatexmkOptions): Promise<string> {
if (!mkOptions.quiet) {
message(
`runnning ${mkOptions.engine.pdfEngine} - 1`,
Expand Down Expand Up @@ -107,6 +107,10 @@ export async function generatePdf(mkOptions: LatexmkOptions) {
if (!mkOptions.quiet) {
message("");
}

return mkOptions.outputDir
? join(cwd, mkOptions.outputDir, stem + ".pdf")
: join(cwd, stem + ".pdf");
}

// The first pass compilation of the latex with the ability to discover
Expand Down

0 comments on commit 604611c

Please sign in to comment.