* Format virtual file content using Prettier
(filePath: string, content: string)
| 325 | * Format virtual file content using Prettier |
| 326 | */ |
| 327 | async function formatContent(filePath: string, content: string): Promise<string> { |
| 328 | try { |
| 329 | const parser = filePath.endsWith('.ts') |
| 330 | ? 'typescript' |
| 331 | : filePath.endsWith('.json') |
| 332 | ? 'json' |
| 333 | : undefined; |
| 334 | if (!parser) return content; |
| 335 | |
| 336 | return await format(content, { |
| 337 | parser, |
| 338 | singleQuote: true, |
| 339 | trailingComma: 'all', |
| 340 | printWidth: 100, |
| 341 | quoteProps: 'preserve', |
| 342 | }); |
| 343 | } catch (e) { |
| 344 | console.warn(`Failed to format ${filePath}:`, e); |
| 345 | return content; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Run the test pipeline with virtual files |
no test coverage detected