MCPcopy Create free account
hub / github.com/ReactTooltip/react-tooltip / runCommand

Function runCommand

benchmarks/run-scaling-series.mjs:102–136  ·  view source on GitHub ↗
(command, commandArgs, { label } = {})

Source from the content-addressed store, hash-verified

100}
101
102function runCommand(command, commandArgs, { label } = {}) {
103 return new Promise((resolve, reject) => {
104 const child = spawn(command, commandArgs, {
105 stdio: ['ignore', 'pipe', 'pipe'],
106 shell: false,
107 })
108
109 const stdoutCleanup = pipeChildOutput(child.stdout, `[${label}]`)
110 const stderrCleanup = pipeChildOutput(child.stderr, `[${label}][stderr]`)
111
112 child.on('error', (error) => {
113 stdoutCleanup()
114 stderrCleanup()
115 reject(error)
116 })
117
118 child.on('exit', (code, signal) => {
119 stdoutCleanup()
120 stderrCleanup()
121
122 if (code === 0) {
123 resolve()
124 return
125 }
126
127 reject(
128 new Error(
129 signal
130 ? `${command} ${commandArgs.join(' ')} exited with signal ${signal}`
131 : `${command} ${commandArgs.join(' ')} exited with code ${code}`,
132 ),
133 )
134 })
135 })
136}
137
138function buildRunTasks(totalRuns) {
139 return Array.from({ length: totalRuns }, (_, index) => ({

Callers 2

runWorkerLoopFunction · 0.70
mainFunction · 0.70

Calls 1

pipeChildOutputFunction · 0.85

Tested by

no test coverage detected