Skip to content

Commit 169549e

Browse files
authored
Merge branch 'main' into bugfix/project-temp-cleanup-2
2 parents 810bbe1 + c6994ae commit 169549e

File tree

14 files changed

+386
-177
lines changed

14 files changed

+386
-177
lines changed

news/changelog-1.7.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,27 @@ All changes included in 1.7:
4141

4242
- ([#12042](https://github.com/quarto-dev/quarto-cli/issues/12042)): Preserve Markdown content that follows YAML metadata in a `raw` .ipynb cell.
4343

44+
## `quarto inspect`
45+
46+
- ([#12336](https://github.com/quarto-dev/quarto-cli/issues/12336)): Clean up transient files created by `quarto inspect`.
47+
4448
## `html` format
4549

4650
- ([#12277](https://github.com/quarto-dev/quarto-cli/pull/12277)): Provide light and dark plot and table renderings with `renderings: [light,dark]`
4751
- ([#11860](https://github.com/quarto-dev/quarto-cli/issues/11860)): ES6 modules that import other local JS modules in documents with `embed-resources: true` are now correctly embedded.
4852
- ([#1325](https://github.com/quarto-dev/quarto-cli/issues/1325)): Dark Mode pages should not flash light on reload. (Nor should Light Mode pages flash dark.)
53+
- ([#12307](https://github.com/quarto-dev/quarto-cli/issues/12307)): Tabsets using `tabby.js` in non-boostrap html (`theme: pandoc`, `theme: none` or `minimal: true`) now correctly render reactive content when `server: shiny` is used.
4954

5055
## `pdf` format
5156

5257
- ([#11835](https://github.com/quarto-dev/quarto-cli/issues/11835)): Take markdown structure into account when detecting minimum heading level.
5358
- ([#11903](https://github.com/quarto-dev/quarto-cli/issues/11903)): `crossref` configuration like `fig-title` or `tbl-title` now correctly supports multi word values, e.g. `fig-title: 'Supplementary Figure'`.
5459
- ([#11878](https://github.com/quarto-dev/quarto-cli/issues/11878), [#12085](https://github.com/quarto-dev/quarto-cli/issues/12085)): Correctly fixup raw LaTeX table having an unexpected table env with options (e.g `\begin{table}[!ht]`) to be handled as crossref table.
5560

61+
## `revealjs` format
62+
63+
- ([#12307](https://github.com/quarto-dev/quarto-cli/issues/12307)): Tabsets using `tabby.js` in Revealjs now correctly render reactive content when `server: shiny` is used.
64+
5665
### Quarto PDF engine
5766

5867
- ([#12194](https://github.com/quarto-dev/quarto-cli/issues/12194)): More specific checks added in log parsing to automatically find missing fonts.

src/project/project-context.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { ExecutionEngine, kMarkdownEngine } from "../execute/types.ts";
6969
import { projectResourceFiles } from "./project-resources.ts";
7070

7171
import {
72+
cleanupFileInformationCache,
7273
ignoreFieldsForProjectType,
7374
normalizeFormatYaml,
7475
projectConfigFile,
@@ -268,6 +269,7 @@ export async function projectContext(
268269
dir: join(dir, ".quarto"),
269270
prefix: "quarto-session-temp",
270271
});
272+
const fileInformationCache = new Map();
271273
const result: ProjectContext = {
272274
resolveBrand: async (fileName?: string) =>
273275
projectResolveBrand(result, fileName),
@@ -287,7 +289,7 @@ export async function projectContext(
287289
},
288290
dir,
289291
engines: [],
290-
fileInformationCache: new Map(),
292+
fileInformationCache,
291293
files: {
292294
input: [],
293295
},
@@ -313,6 +315,7 @@ export async function projectContext(
313315
diskCache: await createProjectCache(join(dir, ".quarto")),
314316
temp,
315317
cleanup: () => {
318+
cleanupFileInformationCache(result);
316319
result.diskCache.close();
317320
temp.cleanup();
318321
},
@@ -362,6 +365,7 @@ export async function projectContext(
362365
dir: join(dir, ".quarto"),
363366
prefix: "quarto-session-temp",
364367
});
368+
const fileInformationCache = new Map();
365369
const result: ProjectContext = {
366370
resolveBrand: async (fileName?: string) =>
367371
projectResolveBrand(result, fileName),
@@ -382,7 +386,7 @@ export async function projectContext(
382386
dir,
383387
config: projectConfig,
384388
engines: [],
385-
fileInformationCache: new Map(),
389+
fileInformationCache,
386390
files: {
387391
input: [],
388392
},
@@ -405,6 +409,7 @@ export async function projectContext(
405409
diskCache: await createProjectCache(join(dir, ".quarto")),
406410
temp,
407411
cleanup: () => {
412+
cleanupFileInformationCache(result);
408413
result.diskCache.close();
409414
temp.cleanup();
410415
},
@@ -434,6 +439,7 @@ export async function projectContext(
434439
dir: join(originalDir, ".quarto"),
435440
prefix: "quarto-session-temp",
436441
});
442+
const fileInformationCache = new Map();
437443
const context: ProjectContext = {
438444
resolveBrand: async (fileName?: string) =>
439445
projectResolveBrand(context, fileName),
@@ -458,7 +464,7 @@ export async function projectContext(
458464
[kProjectOutputDir]: flags?.outputDir,
459465
},
460466
},
461-
fileInformationCache: new Map(),
467+
fileInformationCache,
462468
files: {
463469
input: [],
464470
},
@@ -481,6 +487,7 @@ export async function projectContext(
481487
diskCache: await createProjectCache(join(temp.baseDir, ".quarto")),
482488
temp,
483489
cleanup: () => {
490+
cleanupFileInformationCache(context);
484491
context.diskCache.close();
485492
temp.cleanup();
486493
},

src/project/project-shared.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 2020-2022 Posit Software, PBC
55
*/
66

7-
import { existsSync } from "../deno_ral/fs.ts";
7+
import { existsSync, safeRemoveSync } from "../deno_ral/fs.ts";
88
import {
99
dirname,
1010
isAbsolute,
@@ -582,3 +582,27 @@ export async function projectResolveBrand(
582582
}
583583
}
584584
}
585+
586+
export function cleanupFileInformationCache(project: ProjectContext) {
587+
project.fileInformationCache.forEach((entry) => {
588+
if (entry?.target?.data) {
589+
const data = entry.target.data as {
590+
transient?: boolean;
591+
};
592+
if (data.transient && entry.target?.input) {
593+
safeRemoveSync(entry.target?.input);
594+
}
595+
}
596+
});
597+
}
598+
599+
export async function withProjectCleanup<T>(
600+
project: ProjectContext,
601+
fn: (project: ProjectContext) => Promise<T>,
602+
): Promise<T> {
603+
try {
604+
return await fn(project);
605+
} finally {
606+
project.cleanup();
607+
}
608+
}

0 commit comments

Comments
 (0)