generate_sample_config 988 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. #
  3. # Update/check the docs/sample_config.yaml
  4. set -e
  5. cd `dirname $0`/..
  6. SAMPLE_CONFIG="docs/sample_config.yaml"
  7. SAMPLE_LOG_CONFIG="docs/sample_log_config.yaml"
  8. check() {
  9. diff -u "$SAMPLE_LOG_CONFIG" <(./scripts/generate_log_config) >/dev/null || return 1
  10. }
  11. if [ "$1" == "--check" ]; then
  12. diff -u "$SAMPLE_CONFIG" <(./scripts/generate_config --header-file docs/.sample_config_header.yaml) >/dev/null || {
  13. echo -e "\e[1m\e[31m$SAMPLE_CONFIG is not up-to-date. Regenerate it with \`scripts-dev/generate_sample_config\`.\e[0m" >&2
  14. exit 1
  15. }
  16. diff -u "$SAMPLE_LOG_CONFIG" <(./scripts/generate_log_config) >/dev/null || {
  17. echo -e "\e[1m\e[31m$SAMPLE_LOG_CONFIG is not up-to-date. Regenerate it with \`scripts-dev/generate_sample_config\`.\e[0m" >&2
  18. exit 1
  19. }
  20. else
  21. ./scripts/generate_config --header-file docs/.sample_config_header.yaml -o "$SAMPLE_CONFIG"
  22. ./scripts/generate_log_config -o "$SAMPLE_LOG_CONFIG"
  23. fi