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