MCPcopy Create free account
hub / github.com/garrytan/gstack / run

Function run

test/gstack-artifacts-init.test.ts:123–144  ·  view source on GitHub ↗
(argv: string[], opts: { env?: Record<string, string>; input?: string } = {})

Source from the content-addressed store, hash-verified

121}
122
123function run(argv: string[], opts: { env?: Record<string, string>; input?: string } = {}) {
124 // Include the bin/ dir so artifacts-init can find artifacts-url.
125 const binDir = path.join(ROOT, 'bin');
126 const env = {
127 PATH: `${fakeBinDir}:${binDir}:/usr/bin:/bin:/opt/homebrew/bin`,
128 GSTACK_HOME: tmpHome,
129 USER: 'testuser',
130 HOME: tmpHome,
131 ...(opts.env || {}),
132 };
133 const res = spawnSync(INIT_BIN, argv, {
134 env,
135 encoding: 'utf-8',
136 input: opts.input,
137 cwd: ROOT,
138 });
139 return {
140 stdout: res.stdout || '',
141 stderr: res.stderr || '',
142 status: res.status ?? -1,
143 };
144}
145
146function readCalls(file: string): string[] {
147 if (!fs.existsSync(file)) return [];

Callers 1

Calls 1

spawnSyncFunction · 0.85

Tested by

no test coverage detected