Lines 71-122javascript
71 console.log(data.reused ? 'daemon: reused' : `daemon: started on port ${data.port}`)
74function openBrowser(link, enabled) {
76 const opener = process.platform === 'darwin' ? 'open'
77 : process.platform === 'win32' ? 'start' : 'xdg-open'
78 spawn(opener, [link], { shell: true, stdio: 'ignore', detached: true }).unref()
81function startServer({ args, initialPath = null, dev }) {
82 if (initialPath && !fs.existsSync(initialPath)) {
83 throw new Error(`File not found: ${initialPath}`)
85 if (!dev && !fs.existsSync(DIST)) {
86 throw new Error('Built client not found. Run `npm run build` before starting the production server.')
89 const vitePort = args.port + 1
90 const previewPort = dev ? vitePort : args.port
91 const query = initialPath ? `?path=${encodeURIComponent(initialPath)}` : ''
92 const link = `http://localhost:${previewPort}${query}`
94 const server = http.createServer(createHandler({
103 viteProc = spawn('npx', ['vite', '--host', '127.0.0.1', '--port', String(vitePort), '--strictPort'], {
104 cwd: ROOT,
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
server/cli.jsView on unpkg · L102 105 env: { ...process.env, RMD_SERVER_PORT: String(args.port) },
106 stdio: ['ignore', 'pipe', 'inherit'],
HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
server/cli.jsView on unpkg · L91 107 shell: process.platform === 'win32',
109 let viteReady = false
110 viteProc.stdout.on('data', (chunk) => {
111 process.stdout.write(chunk)
112 if (!viteReady && /ready in/.test(chunk)) {
114 openBrowser(link, args.open)
117 process.on('exit', () => viteProc?.kill())
118 process.on('SIGINT', () => { viteProc?.kill(); process.exit(0) })
121 server.listen(args.port, '0.0.0.0', () => {
122 const lanIps = getLanIps()