| 400 | > |
| 401 | |
| 402 | export function stripIndent(str: string): string { |
| 403 | const normalized = str.replace(/\t/g, ' ') |
| 404 | const match = normalized.match(/^[ \t]*(?=\S)/gm) |
| 405 | if (!match) { |
| 406 | return normalized |
| 407 | } |
| 408 | const indent = match.filter(m => !!m).reduce((min, line) => Math.min(min, line.length), Infinity) |
| 409 | if (indent === 0) { |
| 410 | return normalized |
| 411 | } |
| 412 | return normalized.replace(new RegExp(`^[ ]{${indent}}`, 'gm'), '') |
| 413 | } |
| 414 | |
| 415 | function getGeneratedFileContent(content: TestFsStructure[string]) { |
| 416 | if (typeof content === 'string') { |