-
Notifications
You must be signed in to change notification settings - Fork 478
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
cli: Implement d2 fmt --check #2253
base: master
Are you sure you want to change the base?
Conversation
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.
💯 thorough PR!
gotFoo := readFile(t, dir, "foo.d2") | ||
gotBar := readFile(t, dir, "bar.d2") | ||
assert.Equal(t, "a ---> b", string(gotFoo)) | ||
assert.Equal(t, "x ---> y", string(gotBar)) |
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.
can you extend this to have d2 fmt --check
run on formatted files?
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.
Done in 7cb58fc. I added a formatted file to this first test case, and also added another one where all the files are already formatted correctly.
This PR implements a
--check
flag as described in #1180. I followed what Prettier does: it logs a warning for each unformatted file, and if any were found, it prints the number of unformatted files and a "run XYZ to fix" message.Closes #1180.