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

cameri / nostream / 25601018106

09 May 2026 12:22PM UTC coverage: 33.99% (-31.1%) from 65.107%
25601018106

Pull #615

github

web-flow
Merge 1ef509ec3 into 36e5af87e
Pull Request #615: test: add unit tests for remaining app workers (#489)

788 of 3170 branches covered (24.86%)

Branch coverage included in aggregate %.

0 of 8 new or added lines in 2 files covered. (0.0%)

1822 existing lines in 87 files now uncovered.

2352 of 6068 relevant lines covered (38.76%)

13.55 hits per line

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

0.0
/src/cli/utils/process.ts
UNCOV
1
import { spawn } from 'child_process'
×
2

3
export type RunOptions = {
4
  cwd?: string
5
  env?: NodeJS.ProcessEnv
6
  stdio?: 'inherit' | 'pipe'
7
  timeoutMs?: number
8
}
9

10
export type CommandResult =
11
  | { ok: true; code: number; stdout: string; stderr: string }
12
  | { ok: false; reason: 'not-found' | 'permission-denied' | 'spawn-error' | 'timeout' | 'signal'; stdout: string; stderr: string }
13

UNCOV
14
export const runCommand = (command: string, args: string[], options: RunOptions = {}): Promise<number> => {
×
15
  return new Promise((resolve, reject) => {
×
16
    const child = spawn(command, args, {
×
17
      cwd: options.cwd,
18
      env: { ...process.env, ...(options.env ?? {}) },
×
19
      stdio: options.stdio ?? 'inherit',
×
20
      shell: false,
21
    })
22

23
    const timer =
24
      typeof options.timeoutMs === 'number'
×
25
        ? setTimeout(() => {
26
            child.kill('SIGTERM')
×
27
          }, options.timeoutMs)
28
        : undefined
29

30
    child.on('error', reject)
×
31
    child.on('close', (code) => {
×
32
      if (timer) {
×
33
        clearTimeout(timer)
×
34
      }
35

36
      resolve(code ?? 1)
×
37
    })
38
  })
39
}
40

UNCOV
41
export const runCommandWithOutput = (
×
42
  command: string,
43
  args: string[],
44
  options: RunOptions = {},
×
45
): Promise<CommandResult> => {
46
  return new Promise((resolve) => {
×
47
    let stdout = ''
×
48
    let stderr = ''
×
49
    let timedOut = false
×
50
    let settled = false
×
51

52
    const settle = (result: CommandResult) => {
×
53
      if (!settled) {
×
54
        settled = true
×
55
        resolve(result)
×
56
      }
57
    }
58

59
    const child = spawn(command, args, {
×
60
      cwd: options.cwd,
61
      env: { ...process.env, ...(options.env ?? {}) },
×
62
      stdio: 'pipe',
63
      shell: false,
64
    })
65

66
    const timer =
67
      typeof options.timeoutMs === 'number'
×
68
        ? setTimeout(() => {
69
            timedOut = true
×
70
            child.kill('SIGTERM')
×
71
          }, options.timeoutMs)
72
        : undefined
73

74
    child.stdout.on('data', (chunk) => {
×
75
      stdout += chunk.toString()
×
76
    })
77

78
    child.stderr.on('data', (chunk) => {
×
79
      stderr += chunk.toString()
×
80
    })
81

82
    child.on('error', (err: NodeJS.ErrnoException) => {
×
83
      if (timer) { clearTimeout(timer) }
×
84
      if (err.code === 'ENOENT') {
×
85
        settle({ ok: false, reason: 'not-found', stdout, stderr })
×
86
      } else if (err.code === 'EACCES') {
×
87
        settle({ ok: false, reason: 'permission-denied', stdout, stderr })
×
88
      } else {
89
        settle({ ok: false, reason: 'spawn-error', stdout, stderr })
×
90
      }
91
    })
92

93
    child.on('close', (code, signal) => {
×
94
      if (timer) { clearTimeout(timer) }
×
95

96
      if (timedOut) {
×
97
        settle({ ok: false, reason: 'timeout', stdout, stderr })
×
98
        return
×
99
      }
100

101
      if (signal !== null && code === null) {
×
102
        settle({ ok: false, reason: 'signal', stdout, stderr })
×
103
        return
×
104
      }
105

106
      settle({ ok: true, code: code ?? 1, stdout, stderr })
×
107
    })
108
  })
109
}
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