-
Notifications
You must be signed in to change notification settings - Fork 432
Expand file tree
/
Copy pathenvironment.ts
More file actions
30 lines (28 loc) · 1.04 KB
/
environment.ts
File metadata and controls
30 lines (28 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
* environment.ts
*
* Copyright (C) 2024 Posit Software, PBC
*/
import { basename, dirname } from "../deno_ral/path.ts";
import { ExecuteOptions } from "./types.ts";
import { InternalError } from "../core/lib/error.ts";
export const setExecuteEnvironment: (options: ExecuteOptions) => void = (
options,
) => {
if (options.projectDir) {
options.env["QUARTO_PROJECT_ROOT"] = options.projectDir;
options.env["QUARTO_DOCUMENT_PATH"] = dirname(options.target.source);
options.env["QUARTO_DOCUMENT_FILE"] = basename(options.target.source);
} else {
// FIXME: This should not be passthrough anymore as singleFileProjectContext always set `options.projectDir`
// https://github.com/quarto-dev/quarto-cli/pull/8771
if (!options.cwd) {
throw new InternalError(
"No project directory or current working directory",
);
}
options.env["QUARTO_PROJECT_ROOT"] = options.cwd;
options.env["QUARTO_DOCUMENT_PATH"] = options.cwd;
options.env["QUARTO_DOCUMENT_FILE"] = basename(options.target.source);
}
};