Skip to content

Commit

Permalink
Provide a better error message when format-resource doesn’t exists
Browse files Browse the repository at this point in the history
Fixes #2291
  • Loading branch information
dragonstyle committed Sep 6, 2022
1 parent 0facbe6 commit c7c9d48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/changelog-1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- HTML dependencies may now include `serviceworkers`, which are copied into the output directory.
- New `quarto.doc.attachToDependency` function to attach files to html dependencies (copies files into the lib dir for a named HTML dependency).
- Ensure that `quarto.utils.dump` works with pandoc's builtin global variables (#2254)
- Provide a better error message for non-existent format resources (#2291)

## HTML Format

Expand Down
9 changes: 8 additions & 1 deletion src/command/render/pandoc-dependencies-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
appendDependencies,
FormatResourceDependency,
} from "./pandoc-dependencies.ts";
import { existsSync } from "https://deno.land/[email protected]/fs/exists.ts";

export interface FormatResource {
file: string;
Expand All @@ -32,9 +33,15 @@ export function writeFormatResources(
: [formatResources];

const dependencies: FormatResourceDependency[] = files.map((file) => {
const absPath = join(inputDir, file);
if (!existsSync(absPath)) {
throw new Error(
`The referenced format resource '${file}' does not exist.`,
);
}
return {
type: kFormatResources,
content: { file: join(inputDir, file) },
content: { file: absPath },
};
});
appendDependencies(dependenciesFile, dependencies);
Expand Down

0 comments on commit c7c9d48

Please sign in to comment.