Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/core/api/path.ts
6458 views
1
// src/core/api/path.ts
2
3
import { globalRegistry } from "./registry.ts";
4
import type { PathNamespace } from "./types.ts";
5
6
// Import implementations
7
import {
8
dirAndStem,
9
isQmdFile,
10
normalizePath,
11
pathWithForwardSlashes,
12
} from "../path.ts";
13
import { quartoDataDir, quartoRuntimeDir } from "../appdirs.ts";
14
import { resourcePath } from "../resources.ts";
15
import { inputFilesDir } from "../render.ts";
16
17
// Register path namespace
18
globalRegistry.register("path", (): PathNamespace => {
19
return {
20
absolute: normalizePath,
21
toForwardSlashes: pathWithForwardSlashes,
22
runtime: quartoRuntimeDir,
23
resource: (...parts: string[]) => {
24
if (parts.length === 0) {
25
return resourcePath();
26
} else if (parts.length === 1) {
27
return resourcePath(parts[0]);
28
} else {
29
// Join multiple parts with the first one
30
const joined = parts.join("/");
31
return resourcePath(joined);
32
}
33
},
34
dirAndStem,
35
isQmdFile,
36
inputFilesDir,
37
dataDir: quartoDataDir,
38
};
39
});
40
41