MCPcopy Create free account
hub / github.com/coderoad/coderoad-vscode / runCommands

Function runCommands

src/services/hooks/utils/runCommands.ts:5–30  ·  view source on GitHub ↗
(commands: string[] = [])

Source from the content-addressed store, hash-verified

3import logger from '../../logger'
4
5const runCommands = async (commands: string[] = []): Promise<void> => {
6 if (!commands.length) {
7 return
8 }
9 for (const command of commands) {
10 const process = {
11 title: command,
12 description: 'Running process...',
13 }
14 logger(`Command: ${command}`)
15 send({ type: 'COMMAND_START', payload: { process: { ...process, status: 'RUNNING' } } })
16 let result: { stdout: string; stderr: string }
17 try {
18 result = await exec({ command })
19 if (result.stderr) {
20 throw new Error(result.stderr)
21 }
22 logger(`Command output: ${result.stdout}`)
23 } catch (error: any) {
24 logger(`Command failed: ${error.message}`)
25 send({ type: 'COMMAND_FAIL', payload: { process: { ...process, status: 'FAIL' } } })
26 return
27 }
28 send({ type: 'COMMAND_SUCCESS', payload: { process: { ...process, status: 'SUCCESS' } } })
29 }
30}
31
32export default runCommands

Callers 6

onInitFunction · 0.85
onLevelEnterFunction · 0.85
onSetupEnterFunction · 0.85
onSolutionEnterFunction · 0.85
onResetFunction · 0.85
onContinueFunction · 0.85

Calls 3

sendFunction · 0.90
execFunction · 0.90
loggerFunction · 0.50

Tested by

no test coverage detected