| 17 | const env = { ...process.env, CODEGRAPH_TELEMETRY: '0', DO_NOT_TRACK: '1', CODEGRAPH_NO_PROMPT_HOOK: '1' }; |
| 18 | |
| 19 | function shell(script: string, args: string[] = [], extraEnv: NodeJS.ProcessEnv = {}, input?: string) { |
| 20 | // A file avoids Windows command-line quoting altering the recipe's printf |
| 21 | // escapes or our argument fixtures before Bash even reads them. |
| 22 | const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph-shell-')); |
| 23 | roots.push(root); |
| 24 | const file = path.join(root, 'test.sh'); |
| 25 | const quote = (value: string) => "'" + value.replace(/'/g, "'\\''") + "'"; |
| 26 | fs.writeFileSync(file, `set -- ${args.map(quote).join(' ')}\n${script}`); |
| 27 | return spawnSync(bash, ['--noprofile', '--norc', file], { |
| 28 | encoding: 'utf8', timeout: 30_000, env: { ...env, ...extraEnv }, input, |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | function stage(osfam = windows ? 'win32' : process.platform) { |
| 33 | const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codegraph bundle space ')); |