(argv: string[], opts: { env?: Record<string, string>; input?: string } = {})
| 121 | } |
| 122 | |
| 123 | function 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 | |
| 146 | function readCalls(file: string): string[] { |
| 147 | if (!fs.existsSync(file)) return []; |
no test coverage detected