Skip to content

Commit

Permalink
chore: Add YAML formatting script
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Oct 30, 2022
1 parent 370f4a4 commit 94337dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ format: ensure-gofumpt
find . -name \*.go | xargs ./bin/gofumpt -extra -w
find . -name \*.txtar | xargs ${GO} run ./internal/cmds/lint-txtar -w

.PHONY: format-yaml
format-yaml:
find . -name \*.yaml -o -name \*.yml | xargs ./assets/scripts/format-yaml.py

.PHONY: create-syso ensure-goversioninfo
create-syso: ensure-goversioninfo
${GO} run ./internal/cmds/execute-template -output ./versioninfo.json ./assets/templates/versioninfo.json.tmpl
Expand Down
18 changes: 18 additions & 0 deletions assets/scripts/format-yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python3

import sys

from ruamel.yaml import YAML


def main():
yaml = YAML()
for filename in sys.argv[1:]:
with open(filename) as file:
data = yaml.load(file)
with open(filename, 'w') as file:
yaml.dump(data, file)


if __name__ == '__main__':
main()

0 comments on commit 94337dc

Please sign in to comment.