-
Notifications
You must be signed in to change notification settings - Fork 44
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
File that only contains contents is emptied #91
Comments
This might be related to #74..... |
Hi @hartzell, thanks for opening an issue! This is an unfortunate consequence of the way the yaml library opts to process comments. Comments in
Changing the behaviour of comments being stripped from a yaml file that consists only of comment content is something I probably will not pursue. It would require too many fundamental changes to parsing in the library, and I am trying to be careful not to touch the lexer and parser in As for adjusting
So unless there is some resounding response that the default should be swapped, I think I will leave that default where it is. |
That all makes sense, thank you for the investigation and the detailed explanation. The challenge that I have is that, given the files that I'm working with (that are generated by external tools that I can't change) is that the only safe thing to do is run with Could |
See this section of the README for an explanation of the priority order that I do plan eventually to address #88, to pass configuration through command line flags. This won't be quite as simple as it sounds so I haven't prioritized it yet, but I do plan to allow for it in some fashion eventually. |
Thank you for all the help here. This will work well for our needs. Appreciate all your efforts! |
I have a file,
namespace/collection/meta/runtime.yml
that is generated by the Ansible Galaxy collection init step, that starts off like so:And continues with only blank or commented lines.
When I run
yamlfmt -dstar '**/*yml'
from the top of the directory tree,yamlfmt
deletes all of the content in the file, resulting in a 0 byte file.If I manually add a
---
separator at the start of the file, thenyamlfmt -dstar '**/*yml'
does not strip all of the content. It does, however, strip the---
so the next run empties the file.If I manually add a
---
to the file and use this config file:then the file is not emptied.
I see two things that might be addressed:
include_document_start
totrue
(this gives me a work around).The text was updated successfully, but these errors were encountered: