Hacker News new | ask | show | jobs
by cfors 1622 days ago
In today's world of excellent CLI tools I don't think grep is a good choice, especially for checking irregular languages like XML. [0]

I use tools like `jq` [1] or `yq` [2] all the time for CI checks. One useful check, is we have a configuration file stored as several hundred lines of YAML. Its a nice thing to maintain a sorted order for that, so we have a git pre-commit hook that runs the following:

> yq eval --inplace '.my_key|= sort' my_file.yaml

Of course, a pre-commit hook or CI both work. There's pros and cons of both. For our team, the pre-commit hook is a low enough level of effort, and doesn't require a CI check for something that executes in milliseconds.

[0] https://stackoverflow.com/a/1732454

[1] https://github.com/stedolan/jq

[2] https://github.com/mikefarah/yq