| 27 | const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests'; |
| 28 | |
| 29 | function asyncExec( |
| 30 | command: string | string[], |
| 31 | options: { env: Record<string, string | undefined>; cwd: string }, |
| 32 | ): Promise<void> { |
| 33 | return new Promise((resolve, reject) => { |
| 34 | // If command is an array, use spawn with separate command and args (safer) |
| 35 | // If command is a string, maintain backward compatibility with shell: true |
| 36 | let process: ReturnType<typeof spawn>; |
| 37 | if (typeof command === 'string') { |
| 38 | process = spawn(command, { ...options, shell: true }); |
| 39 | } else { |
| 40 | if (command.length === 0) { |
| 41 | return reject(new Error('Command array cannot be empty')); |
| 42 | } |
| 43 | const cmd = command[0]; |
| 44 | if (!cmd) { |
| 45 | return reject(new Error('Command array cannot be empty')); |
| 46 | } |
| 47 | process = spawn(cmd, command.slice(1), { ...options, shell: false }); |
| 48 | } |
| 49 | |
| 50 | if (process.stdout) { |
| 51 | process.stdout.on('data', data => { |
| 52 | console.log(`${data}`); |
| 53 | }); |
| 54 | } |
| 55 | |
| 56 | if (process.stderr) { |
| 57 | process.stderr.on('data', data => { |
| 58 | console.error(`${data}`); |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | process.on('error', error => { |
| 63 | reject(error); |
| 64 | }); |
| 65 | |
| 66 | process.on('close', code => { |
| 67 | if (code !== 0) { |
| 68 | return reject(); |
| 69 | } |
| 70 | resolve(); |
| 71 | }); |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | function findMatchingVariant(variants: SentryTestVariant[], variantLabel: string): SentryTestVariant | undefined { |
| 76 | const variantLabelLower = variantLabel.toLowerCase(); |