Skip to content

Conversation

clydin
Copy link
Member

@clydin clydin commented Apr 19, 2022

The schematics Tree now contains an additional readText method that supports directly
reading the content of a file as UTF-8 text. This avoids the need to manually decode a Buffer
within a schematic when text content is needed. If a file path does not exist, an exception
will be thrown. While this differs from the semantics of read, it helps reduce the amount
of code needed for common schematic use cases.

The schematics Tree now contains an additional readJSON method that supports directly
reading and parsing the content of a file as UTF-8 JSON with comment support. This avoids the need to manually
decode a Buffer, parse and handle JSON comments within a schematic when JSON content is needed.
If a file path does not exist, an exception will be thrown. While this differs from the semantics of read,
it helps reduce the amount of code needed for common schematic use cases. JSON parse errors will also result
in an exception being thrown with a message detailing the error.

@clydin clydin added the target: major This PR is targeted for the next major release label Apr 19, 2022
@clydin clydin force-pushed the schematics/tree-readtext branch from 3a3af1f to fdfc3cc Compare April 19, 2022 16:19
@clydin clydin marked this pull request as ready for review April 20, 2022 00:16
@clydin clydin force-pushed the schematics/tree-readtext branch from fdfc3cc to 691133f Compare April 20, 2022 16:55
@clydin clydin requested a review from dgp1130 April 20, 2022 19:11
Copy link
Collaborator

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting up the commits and taking the time to update existing usages. The readJSON() improvements seem particularly nice.

@clydin clydin force-pushed the schematics/tree-readtext branch 3 times, most recently from fa10db3 to 87cbc51 Compare April 25, 2022 16:07
clydin added 2 commits April 25, 2022 12:23
…ly from a Tree

The schematics `Tree` now contains an additional `readText` method that supports directly
reading the content of a file as UTF-8 text. This avoids the need to manually decode a Buffer
within a schematic when text content is needed. If a file path does not exist, an exception
will be thrown. While this differs from the semantics of `read`, it helps reduce the amount
of code needed for common schematic use cases.
…ly from a Tree

The schematics `Tree` now contains an additional `readJSON` method that supports directly
reading and parsing the content of a file as UTF-8 JSON with comment support. This avoids the need to manually
decode a Buffer, parse and handle JSON comments within a schematic when JSON content is needed.
If a file path does not exist, an exception will be thrown. While this differs from the semantics of `read`,
it helps reduce the amount of code needed for common schematic use cases. JSON parse errors will also result
in an exception being thrown with a message detailing the error.
@clydin clydin force-pushed the schematics/tree-readtext branch from 87cbc51 to c7f1642 Compare April 25, 2022 16:23
… and `readJSON` functionality

Code related to decoding buffers into strings and parsing content into JSON can now be removed by using the
support provided directly from the Tree instance for the executing schematic.
@clydin clydin force-pushed the schematics/tree-readtext branch from c7f1642 to b3c4229 Compare April 25, 2022 16:35
@dgp1130 dgp1130 added this to the v14 milestone Apr 25, 2022
@clydin clydin requested a review from dgp1130 April 26, 2022 13:42
@clydin clydin added the action: merge The PR is ready for merge by the caretaker label Apr 26, 2022
@clydin clydin merged commit a0e3de2 into angular:master Apr 26, 2022
@clydin clydin deleted the schematics/tree-readtext branch April 26, 2022 23:24
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants