MCPcopy
hub / github.com/shadcn-ui/ui / runCommand

Function runCommand

packages/tests/src/utils/helpers.ts:30–67  ·  view source on GitHub ↗
(
  cwd: string,
  args: string[],
  options?: {
    env?: Record<string, string>
    input?: string
    timeout?: number
  }
)

Source from the content-addressed store, hash-verified

28}
29
30export async function runCommand(
31 cwd: string,
32 args: string[],
33 options?: {
34 env?: Record<string, string>
35 input?: string
36 timeout?: number
37 }
38) {
39 try {
40 const childProcess = execa("node", [SHADCN_CLI_PATH, ...args], {
41 cwd,
42 env: {
43 ...process.env,
44 FORCE_COLOR: "0",
45 CI: "true",
46 ...options?.env,
47 },
48 input: options?.input,
49 reject: false,
50 timeout: options?.timeout ?? 60000,
51 })
52
53 const result = await childProcess
54
55 return {
56 stdout: result.stdout || "",
57 stderr: result.stderr || "",
58 exitCode: result.exitCode ?? 0,
59 }
60 } catch (error: any) {
61 return {
62 stdout: error.stdout || "",
63 stderr: error.stderr || error.message || "",
64 exitCode: error.exitCode ?? 1,
65 }
66 }
67}
68
69export async function npxShadcn(
70 cwd: string,

Callers 3

npxShadcnFunction · 0.85
CommandMenuFunction · 0.85
downFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected