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

Function runCommand

packages/cli/tests-e2e/helpers.ts:39–86  ·  view source on GitHub ↗
(
  command: string,
  args: Array<string>,
  opts: {
    cwd: string
    env?: NodeJS.ProcessEnv
  },
)

Source from the content-addressed store, hash-verified

37}
38
39function runCommand(
40 command: string,
41 args: Array<string>,
42 opts: {
43 cwd: string
44 env?: NodeJS.ProcessEnv
45 },
46) {
47 return new Promise<void>((resolvePromise, rejectPromise) => {
48 const child = spawn(command, args, {
49 cwd: opts.cwd,
50 env: {
51 ...process.env,
52 ...opts.env,
53 },
54 stdio: 'pipe',
55 })
56
57 let stdout = ''
58 let stderr = ''
59
60 child.stdout.on('data', (chunk) => {
61 stdout += String(chunk)
62 })
63
64 child.stderr.on('data', (chunk) => {
65 stderr += String(chunk)
66 })
67
68 child.on('error', (err) => {
69 rejectPromise(err)
70 })
71
72 child.on('close', (code) => {
73 if (code === 0) {
74 resolvePromise()
75 return
76 }
77 rejectPromise(
78 new Error(
79 `${command} ${args.join(' ')} failed with code ${code}\n` +
80 `stdout:\n${stdout}\n\n` +
81 `stderr:\n${stderr}`,
82 ),
83 )
84 })
85 })
86}
87
88function waitForServer(url: string, timeoutMs = 90_000) {
89 const started = Date.now()

Callers 2

runQualityGatesFunction · 0.85
createAppFixtureFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected