MCPcopy Create free account
hub / github.com/TanStack/db / runCommand

Function runCommand

packages/capacitor-db-sqlite-persistence/e2e/run-android-e2e.ts:31–77  ·  view source on GitHub ↗
(
  command: string,
  args: Array<string>,
  options: {
    cwd?: string
    env?: NodeJS.ProcessEnv
    stdio?: `inherit` | `pipe`
  } = {},
)

Source from the content-addressed store, hash-verified

29const resultsDatabaseName = `tanstack_db_capacitor_e2e_results_${runtimeRunId}`
30
31function runCommand(
32 command: string,
33 args: Array<string>,
34 options: {
35 cwd?: string
36 env?: NodeJS.ProcessEnv
37 stdio?: `inherit` | `pipe`
38 } = {},
39): Promise<string> {
40 return new Promise((resolvePromise, rejectPromise) => {
41 let stdout = ``
42 const child = spawn(command, args, {
43 cwd: options.cwd ?? packageDirectory,
44 env: {
45 ...process.env,
46 ...options.env,
47 },
48 stdio:
49 options.stdio === `pipe` ? [`ignore`, `pipe`, `inherit`] : `inherit`,
50 })
51
52 if (options.stdio === `pipe`) {
53 if (!child.stdout) {
54 rejectPromise(new Error(`${command} did not expose stdout`))
55 return
56 }
57
58 child.stdout.on(`data`, (chunk) => {
59 stdout += String(chunk)
60 })
61 }
62
63 child.on(`exit`, (code) => {
64 if (code === 0) {
65 resolvePromise(stdout)
66 return
67 }
68
69 rejectPromise(
70 new Error(
71 `${command} ${args.join(` `)} exited with code ${String(code)}`,
72 ),
73 )
74 })
75 child.on(`error`, rejectPromise)
76 })
77}
78
79function resolveAndroidSdkRoot(): string {
80 const candidates = [

Callers 5

ensureNativeProjectFunction · 0.70
resolveAndroidDeviceIdFunction · 0.70
waitForAndroidBootFunction · 0.70
buildDebugApkFunction · 0.70
installAndLaunchAppFunction · 0.70

Calls 2

onMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected