(outputRoot: string, outputName: string)
| 172 | } |
| 173 | |
| 174 | function safeOutputPath(outputRoot: string, outputName: string): string { |
| 175 | if (!outputName || outputName === '.' || isAbsolute(outputName)) { |
| 176 | throw new Error(`Output name must be a non-empty relative path: ${outputName || '<empty>'}`); |
| 177 | } |
| 178 | const outputPath = resolve(outputRoot, outputName); |
| 179 | if (outputPath === outputRoot) throw new Error(`Output name must identify a file below outputRoot: ${outputName}`); |
| 180 | assertContained(outputRoot, outputPath, `Output path is outside outputRoot: ${outputName}`); |
| 181 | return outputPath; |
| 182 | } |
| 183 | |
| 184 | function assertContained(root: string, candidate: string, message: string): void { |
| 185 | const localPath = relative(root, candidate); |
no test coverage detected