-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdev_server.js
More file actions
35 lines (27 loc) · 1.38 KB
/
dev_server.js
File metadata and controls
35 lines (27 loc) · 1.38 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
import process from 'node:process'
import { exec, execSync, spawnSync, spawn } from 'node:child_process'
import { promisify } from 'node:util'
const execAsync = promisify(exec)
// run a clean documentation build, wait for it to complete
console.log("Building docs from scratch...")
spawnSync("node", ["export.js", "docs"], { stdio: 'inherit', shell: true })
// start the file watcher and incremental builder
console.log("Starting incremental builder and file watcher...")
const docBuilder = spawn("node", ["--watch-path=./app", "export.js", "docs-incremental"], { stdio: 'inherit', shell: true })
docBuilder.on('error', err => console.log('Builder Error:', err))
docBuilder.on('exit', code => console.log('Builder Exited', code === 0 ? "Cleanly" : `With Error Code ${code}`))
// start the Vitepress docs dev server
console.log("Starting Vitepress docs server...")
const docServer = spawn("npm", ["run", "docs:dev"], { stdio: 'inherit', shell: true })
docServer.on('error', err => console.log('Server Error:', err))
docServer.on('exit', code => console.log('Server Exited', code === 0 ? "Cleanly" : `With Error Code ${code}`))
const killAll = () => {
console.log('Shutting down...')
docBuilder.kill()
docServer.kill()
process.exit()
}
// if either one exits, kill the other
console.log("Watching files for changes and servers for crashes")
docServer.on('exit', killAll)
docBuilder.on('exit', killAll)