Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ All changes included in 1.6:

### Websites

- ([#2671](https://github.com/quarto-dev/quarto-cli/issues/2671)): Ensure that `--output-dir` works across filesystem boundaries.
- ([#8932](https://github.com/quarto-dev/quarto-cli/issues/8932)): Escape render ids in markdown pipeline to allow special characters in sidebars/navbars, etc.
- ([#10616](https://github.com/quarto-dev/quarto-cli/issues/10268)): Add a `z-index` setting to the 'back to top' button to ensure it is always visible.

Expand Down
4 changes: 2 additions & 2 deletions src/command/render/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (C) 2020-2022 Posit Software, PBC
*/

import { ensureDirSync, existsSync } from "../../deno_ral/fs.ts";
import { ensureDirSync, existsSync, safeMoveSync } from "../../deno_ral/fs.ts";
import { dirname, isAbsolute, join, relative } from "../../deno_ral/path.ts";
import { info, warning } from "../../deno_ral/log.ts";
import { mergeProjectMetadata } from "../../config/metadata.ts";
Expand Down Expand Up @@ -530,7 +530,7 @@ export async function renderProject(
if (!renderedFile.isTransient) {
const outputFile = join(formatOutputDir, renderedFile.file);
ensureDirSync(dirname(outputFile));
Deno.renameSync(join(projDir, renderedFile.file), outputFile);
safeMoveSync(join(projDir, renderedFile.file), outputFile);
}

// files dir
Expand Down
17 changes: 3 additions & 14 deletions src/core/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import {

import { warning } from "../deno_ral/log.ts";

import { existsSync, expandGlobSync } from "../deno_ral/fs.ts";
export { safeRemoveSync } from "../deno_ral/fs.ts";

import { existsSync, expandGlobSync, safeRemoveSync } from "../deno_ral/fs.ts";

import * as ld from "./lodash.ts";

Expand All @@ -41,19 +43,6 @@ export function safeRemoveIfExists(file: string) {
}
}

export function safeRemoveSync(
file: string,
options: Deno.RemoveOptions = {},
) {
try {
Deno.removeSync(file, options);
} catch (e) {
if (existsSync(file)) {
throw e;
}
}
}

export function removeIfEmptyDir(dir: string): boolean {
if (existsSync(dir)) {
let empty = true;
Expand Down
30 changes: 30 additions & 0 deletions src/deno_ral/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import { fromFileUrl } from "./path.ts";
import { resolve, SEP as SEPARATOR } from "./path.ts";
import { copySync } from "fs/copy";
import { existsSync } from "fs/exists";

export { ensureDir, ensureDirSync } from "fs/ensure-dir";
export { existsSync } from "fs/exists";
Expand Down Expand Up @@ -74,3 +76,31 @@ export function toPathString(
): string {
return pathUrl instanceof URL ? fromFileUrl(pathUrl) : pathUrl;
}

export function safeMoveSync(
src: string,
dest: string,
): void {
try {
Deno.renameSync(src, dest);
} catch (err) {
if (err.code !== "EXDEV") {
throw err;
}
copySync(src, dest, { overwrite: true });
safeRemoveSync(src, { recursive: true });
}
}

export function safeRemoveSync(
file: string,
options: Deno.RemoveOptions = {},
) {
try {
Deno.removeSync(file, options);
} catch (e) {
if (existsSync(file)) {
throw e;
}
}
}
Loading