1
1
import { join } from "node:path" ;
2
+ import { createRequire } from "node:module" ;
2
3
import { createDevApp , defaultTheme , viteBundler } from "vuepress" ;
3
4
import debug from "debug" ;
4
5
import type { CommandOptions } from "@condorhero/vuepress-plugin-export-pdf-core" ;
@@ -9,7 +10,11 @@ import type { UserConfig } from ".";
9
10
10
11
const devDebug = debug ( "vuepress-plugin-export-pdf-v2:dev-server" ) ;
11
12
13
+ export const moduleRequire = createRequire ( import . meta. url ) ;
14
+ const { version } = moduleRequire ( "vuepress/package.json" ) ;
15
+
12
16
export const serverApp = async ( dir = "docs" , commandOptions : CommandOptions = { } ) => {
17
+ checkEnv ( "VuePress" , pkg . engines . node , version , pkg . peerDependencies . vuepress ) ;
13
18
const sourceDir = join ( process . cwd ( ) , dir ) ;
14
19
15
20
if ( commandOptions . debug )
@@ -60,7 +65,6 @@ export const serverApp = async (dir = "docs", commandOptions: CommandOptions = {
60
65
host : "localhost" ,
61
66
port : 8714 ,
62
67
} ) ;
63
- checkEnv ( "VuePress" , pkg . engines . node , devApp . version , pkg . peerDependencies . vuepress ) ;
64
68
65
69
// initialize and prepare
66
70
await devApp . init ( ) ;
@@ -94,6 +98,6 @@ export const serverApp = async (dir = "docs", commandOptions: CommandOptions = {
94
98
}
95
99
96
100
// close current dev server
97
- closeDevServer ( ) ;
101
+ await closeDevServer ( ) ;
98
102
process . exit ( 0 ) ;
99
103
} ;
0 commit comments