MCPcopy Index your code
hub / github.com/angular/angular-cli / formatFiles

Function formatFiles

packages/angular/cli/src/utilities/prettier.ts:23–53  ·  view source on GitHub ↗
(cwd: string, files: Set<string>)

Source from the content-addressed store, hash-verified

21 * @param files The files to format.
22 */
23export async function formatFiles(cwd: string, files: Set<string>): Promise<void> {
24 if (!files.size) {
25 return;
26 }
27
28 if (prettierCliPath === undefined) {
29 try {
30 const prettierPath = createRequire(cwd + '/').resolve('prettier/package.json');
31 const prettierPackageJson = JSON.parse(await readFile(prettierPath, 'utf-8')) as {
32 bin: string;
33 };
34 prettierCliPath = join(dirname(prettierPath), prettierPackageJson.bin);
35 } catch {
36 // Prettier is not installed.
37 prettierCliPath = null;
38 }
39 }
40
41 if (!prettierCliPath) {
42 return;
43 }
44
45 await execFileAsync(
46 process.execPath,
47 [prettierCliPath, '--write', '--no-error-on-unmatched-pattern', '--ignore-unknown', ...files],
48 {
49 cwd,
50 shell: false,
51 },
52 );
53}

Callers 2

runSchematicFunction · 0.90
executePackageMigrationsFunction · 0.90

Calls 4

joinFunction · 0.85
resolveMethod · 0.80
readFileFunction · 0.70
dirnameFunction · 0.50

Tested by

no test coverage detected