MCPcopy Create free account
hub / github.com/angular/angular / formatContent

Function formatContent

packages/compiler-cli/preprocessor/test/utils.ts:327–347  ·  view source on GitHub ↗

* Format virtual file content using Prettier

(filePath: string, content: string)

Source from the content-addressed store, hash-verified

325 * Format virtual file content using Prettier
326 */
327async 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

Callers 3

formatWithPlaceholdersFunction · 0.85
maybeFormatFunction · 0.85
runPipelineFunction · 0.85

Calls 1

warnMethod · 0.65

Tested by

no test coverage detected