-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs-dev.js
More file actions
34 lines (30 loc) · 1003 Bytes
/
Copy pathdocs-dev.js
File metadata and controls
34 lines (30 loc) · 1003 Bytes
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
#!/usr/bin/env node
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { startDocsPreviewServer } from '../../website/serve.js';
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
const options = parseArgs(process.argv.slice(2));
const app = await startDocsPreviewServer({
cwd: path.join(repoRoot, 'website'),
host: options.host,
port: options.port,
skipSync: options.skipSync,
});
console.log(`Docs preview: ${app.url}/`);
console.log(`Built-in viewer: ${app.url}/__db`);
function parseArgs(argv) {
let port = 7340;
let host = '127.0.0.1';
let skipSync = false;
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index];
if (arg === '--port' && argv[index + 1]) {
port = Number(argv[++index]);
} else if (arg === '--host' && argv[index + 1]) {
host = argv[++index];
} else if (arg === '--no-sync') {
skipSync = true;
}
}
return { port, host, skipSync };
}