-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathdoc.ts
More file actions
45 lines (41 loc) · 1.36 KB
/
doc.ts
File metadata and controls
45 lines (41 loc) · 1.36 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* VitePress tool resolver for the vite-plus CLI.
*
* This module exports a function that resolves the VitePress binary path
* using Node.js module resolution. The resolved path is passed back
* to the Rust core, which then executes VitePress for documentation.
*
* Used for: `vite-plus doc` command
*/
import { createRequire } from 'node:module';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const require = createRequire(import.meta.url);
/**
* Resolves the VitePress binary path and environment variables.
*
* @returns Promise containing:
* - binPath: Absolute path to the VitePress CLI entry point
* - envs: Environment variables to set when executing VitePress
*
* VitePress is a Vite & Vue powered static site generator for
* building documentation websites with excellent performance.
*/
export async function doc(): Promise<{
binPath: string;
envs: Record<string, string>;
}> {
// Resolve the VitePress CLI module directly
const binPath = require.resolve('vitepress/bin/vitepress.js', {
paths: [process.cwd(), dirname(fileURLToPath(import.meta.url))],
});
return {
binPath,
// Pass through source map debugging environment variable if set
envs: process.env.DEBUG_DISABLE_SOURCE_MAP
? {
DEBUG_DISABLE_SOURCE_MAP: process.env.DEBUG_DISABLE_SOURCE_MAP,
}
: {},
};
}