MCPcopy Create free account
hub / github.com/appium/appium / spawnBackgroundProcess

Function spawnBackgroundProcess

packages/docutils/lib/utils/process.ts:19–31  ·  view source on GitHub ↗
(command: string, args: string[], opts: SpawnBackgroundProcessOpts = {})

Source from the content-addressed store, hash-verified

17 * `teen_process` basically does not respect `{stdio: 'inherit'}`.
18 */
19export async function spawnBackgroundProcess(command: string, args: string[], opts: SpawnBackgroundProcessOpts = {}) {
20 return new Promise<void>((resolve, reject) => {
21 spawn(command, args, {...opts, stdio: 'inherit'})
22 .on('error', reject)
23 .on('close', (code, signal) => {
24 if (code === 0) {
25 return resolve();
26 }
27 const reason = code === null ? `signal ${signal ?? 'unknown'}` : `code ${code}`;
28 reject(new Error(`${command} exited with ${reason}`));
29 });
30 });
31}
32
33/**
34 * Wraps {@linkcode exec} with error handling that appends stderr to the thrown error message.

Callers 2

doServeFunction · 0.85
doServeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected