• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

skmtc / skmtc / 18418918941

10 Oct 2025 09:31PM UTC coverage: 37.821% (-0.04%) from 37.859%
18418918941

push

github

dmitrigrabov
Update server config

406 of 486 branches covered (83.54%)

Branch coverage included in aggregate %.

0 of 13 new or added lines in 1 file covered. (0.0%)

4170 of 11613 relevant lines covered (35.91%)

11.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.76
/deno/cli/components/ServerTask.tsx
1
import React, { useId, useEffect } from 'react'
3✔
2
import { useState } from 'react'
3
import type { Project } from '@/lib/project.ts'
4
import { useTask } from './TaskContext.tsx'
3✔
5
import { Box } from 'ink'
3✔
6
import { dirname } from '@std/path/dirname'
3✔
7
import { join } from '@std/path/join'
3✔
8
import type { Dispatch, SetStateAction } from 'react'
9

10
type ServerTaskProps = {
11
  project: Project
12
  setChild: Dispatch<SetStateAction<Deno.ChildProcess | undefined>>
13
}
14

15
export const ServerTask = ({ project, setChild }: ServerTaskProps) => {
×
16
  const { dispatch } = useTask()
×
17

18
  useEffect(() => {
×
19
    const serve = async () => {
×
20
      const modPath = await project.createServer()
×
21

NEW
22
      const port = '8001'
×
23

NEW
24
      const serverUrl = `http://localhost:${port}`
×
25

NEW
26
      project.clientJson.contents = project.clientJson.contents
×
NEW
27
        ? {
×
NEW
28
            ...project.clientJson.contents,
×
NEW
29
            serverUrl
×
NEW
30
          }
×
NEW
31
        : {
×
NEW
32
            serverUrl,
×
NEW
33
            settings: {}
×
NEW
34
          }
×
35

NEW
36
      await project.clientJson.write()
×
37

NEW
38
      const child = runServer({ modPath, port })
×
39

40
      setChild(child)
×
41
      dispatch({ type: 'increment-current-task' })
×
42
    }
×
43

44
    serve()
×
45
  }, [])
×
46

47
  return <Box></Box>
×
48

49
  // if (serving) {
50
  //   return (
51
  //     <TaskBox id={`${id}-result`} active={false}>
52
  //       <Spinner label="Serving..." />
53
  //     </TaskBox>
54
  //   )
55
  // }
56

57
  // return (
58
  //   <TaskContainer>
59
  //     <Spinner label="Starting server..." />
60
  //   </TaskContainer>
61
  // )
62
}
×
63

64
type RunServerArgs = {
65
  modPath: string
66
  port: string
67
}
68

69
export const runServer = ({ modPath, port = '8001' }: RunServerArgs) => {
×
70
  const command = new Deno.Command('deno', {
×
71
    args: ['serve', '--allow-env', '--allow-sys', '--port', port, modPath],
×
72
    cwd: dirname(modPath),
×
73
    stdout: 'piped',
×
74
    stderr: 'piped'
×
75
  })
×
76

77
  const logsPath = join(dirname(modPath), '.settings', 'logs.txt')
×
78
  const errorLogsPath = join(dirname(modPath), '.settings', 'error-logs.txt')
×
79

80
  // create subprocess and collect output
81
  const child = command.spawn()
×
82

83
  // Read stdout in the background and write to file
84
  ;(async () => {
×
85
    const reader = child.stdout.getReader()
×
86
    const decoder = new TextDecoder()
×
87
    const file = await Deno.open(logsPath, { create: true, append: true })
×
88
    try {
×
89
      while (true) {
×
90
        const { done, value } = await reader.read()
×
91
        if (done) break
×
92
        const text = decoder.decode(value, { stream: true })
×
93
        await file.write(new TextEncoder().encode(text))
×
94
      }
×
95
    } finally {
×
96
      reader.releaseLock()
×
97
      file.close()
×
98
    }
×
99
  })()
×
100

101
  // Read stderr in the background and write to file
102
  ;(async () => {
×
103
    const reader = child.stderr.getReader()
×
104
    const decoder = new TextDecoder()
×
105
    const file = await Deno.open(errorLogsPath, { create: true, append: true })
×
106
    try {
×
107
      while (true) {
×
108
        const { done, value } = await reader.read()
×
109
        if (done) break
×
110
        const text = decoder.decode(value, { stream: true })
×
111
        await file.write(new TextEncoder().encode(text))
×
112
      }
×
113
    } finally {
×
114
      reader.releaseLock()
×
115
      file.close()
×
116
    }
×
117
  })()
×
118

119
  return child
×
120
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc