-
Notifications
You must be signed in to change notification settings - Fork 11.9k
feat(@angular/cli): automatic formatting files modified by schematics #32367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3cc3fdf to
1b984f1
Compare
| await execFileAsync(prettierCliPath, [ | ||
| '--write', | ||
| ...[...files].filter((f) => fileTypes.has(extname(f))).map((f) => relative(cwd, f)), | ||
| ]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows, this might need the shell option enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we'll see when this is merged.
packages/angular/cli/src/command-builder/schematics-command-module.ts
Outdated
Show resolved
Hide resolved
f5ca400 to
b8a64b8
Compare
This change introduces automatic formatting of files generated or modified during a schematic execution. When a schematic is executed, the CLI will now attempt to find and use the project's local Prettier installation to format all created or updated files. This ensures that generated code adheres to the project's established coding style without requiring developers to manually run a formatting command. If Prettier is not installed in the user's workspace, the formatting step will be gracefully skipped. This avoids adding a direct dependency on Prettier to the CLI and respects the user's project setup. The implementation leverages the Prettier CLI directly for a more robust and reliable formatting process. Closes angular#10777
a10a6ca to
f6721ed
Compare
f6721ed to
fde5365
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This change introduces automatic formatting of files generated or modified during a schematic execution.
When a schematic is executed, the CLI will now attempt to find and use the project's local Prettier installation to format all created or updated files. This ensures that generated code adheres to the project's established coding style without requiring developers to manually run a formatting command.
If Prettier is not installed in the user's workspace, the formatting step will be gracefully skipped. This avoids adding a direct dependency on Prettier to the CLI and respects the user's project setup. The implementation leverages the Prettier CLI directly for a more robust and reliable formatting process.
Closes #10777