| 112 | } |
| 113 | |
| 114 | function captureCommandOutput(command: string, outputFile?: string): string { |
| 115 | if (!outputFile) { |
| 116 | return command |
| 117 | } |
| 118 | |
| 119 | if (!/^[a-zA-Z0-9._-]+$/.test(outputFile)) { |
| 120 | throw new Error( |
| 121 | `[Playwright Sharding Plugin] Invalid E2E_BUILD_LOG value: ${outputFile}. ` + |
| 122 | `Expected a filename containing only letters, numbers, dots, dashes, and underscores.`, |
| 123 | ) |
| 124 | } |
| 125 | |
| 126 | const escapedCommand = command.replaceAll("'", "'\\''") |
| 127 | return `bash -o pipefail -c '{ ${escapedCommand}; } 2>&1 | tee ${outputFile}'` |
| 128 | } |
| 129 | |
| 130 | function getTestOutputs( |
| 131 | modeKey: string, |