( filePath: string, transforms: FileTransform[] )
| 40 | } |
| 41 | |
| 42 | async function applyTransformsOnFileContentAsync( |
| 43 | filePath: string, |
| 44 | transforms: FileTransform[] |
| 45 | ): Promise<{ |
| 46 | content: string; |
| 47 | transformsUsed: Set<FileTransform>; |
| 48 | }> { |
| 49 | // Transform source content. |
| 50 | let result = await fs.readFile(filePath, 'utf8'); |
| 51 | const transformsUsed = new Set<FileTransform>(); |
| 52 | for (const transform of transforms) { |
| 53 | const beforeTransformation = result; |
| 54 | result = applySingleTransform(result, transform); |
| 55 | await maybePrintDebugInfoAsync(beforeTransformation, result, filePath, transform); |
| 56 | if (result !== beforeTransformation) { |
| 57 | transformsUsed.add(transform); |
| 58 | } |
| 59 | } |
| 60 | return { content: result, transformsUsed }; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Filters file contents transformations to only these that match path patterns. |
no test coverage detected
searching dependent graphs…