Skip to content
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

Run prettier on reference files as they are generated #65

Merged
merged 6 commits into from
Jan 5, 2024

Conversation

huonw
Copy link
Contributor

@huonw huonw commented Jan 5, 2024

This does a bunch of leg work to have the reference files be reformatted (with prettier) as they are written. This makes the generation notably slower (slightly less than 1s -> slightly less than 4s on my machine), but saves from having to remember to run the formatting separately... which takes just as long as the extra time anyway.

This requires a few steps, broken across commits in a useful way (with some not-strictly-necessary changes), because prettier only has an async API. This seems to require running as an .mjs ("module") rather than .js to be able to use await at the top level.

After getting to using async + prettier, this then makes a few changes that this allows:

  • a neater way to write the JSON files
  • writing all files concurrently with Promise.all (writing the targets and subsystems concurrently takes the time from ~4.4s -> ~3.8s, doing the others concurrently makes no difference, but makes the code look uniform).

See also: #50 (comment)

@huonw huonw marked this pull request as ready for review January 5, 2024 01:05
@huonw huonw requested a review from thejcannon January 5, 2024 01:05
Copy link
Member

@thejcannon thejcannon left a comment

Choose a reason for hiding this comment

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

That's a work of art :chef's kiss:

@huonw huonw merged commit ddc79c8 into main Jan 5, 2024
1 check passed
@huonw huonw deleted the huonw/prettier-inline branch January 5, 2024 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants