Skip to content

Commit fde5365

Browse files
committed
fixup! feat(@angular/cli): automatic formatting files modified by schematics
1 parent 8a51005 commit fde5365

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/angular/cli/src/command-builder/utilities/prettier.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,16 @@ export async function formatFiles(cwd: string, files: Set<string>): Promise<void
5858
return;
5959
}
6060

61-
await execFileAsync(prettierCliPath, [
62-
'--write',
63-
...[...files].filter((f) => fileTypes.has(extname(f))).map((f) => relative(cwd, f)),
64-
]);
61+
const filesToFormat: string[] = [];
62+
for (const file of files) {
63+
if (fileTypes.has(extname(file))) {
64+
filesToFormat.push(relative(cwd, file));
65+
}
66+
}
67+
68+
if (!filesToFormat.length) {
69+
return;
70+
}
71+
72+
await execFileAsync(prettierCliPath, ['--write', ...filesToFormat], { cwd });
6573
}

tests/e2e/tests/commands/add/add-tailwindcss.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default async function () {
1313
try {
1414
await ng('add', 'tailwindcss', '--skip-confirmation');
1515
await expectFileToExist('.postcssrc.json');
16-
await expectFileToMatch('src/styles.css', /@import "tailwindcss";/);
16+
await expectFileToMatch('src/styles.css', /@import 'tailwindcss';/);
1717
await expectFileToMatch('package.json', /"tailwindcss":/);
1818
await expectFileToMatch('package.json', /"@tailwindcss\/postcss":/);
1919
await expectFileToMatch('package.json', /"postcss":/);

0 commit comments

Comments
 (0)