2
0

update-example-dates.sh 798 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. set -e # always immediately exit upon error
  3. cd "`dirname $0`/.." # start in project root
  4. ./scripts/require-clean-working-tree.sh examples
  5. read -p "Do you want to update the example dates? (y/N): " yn
  6. if [[ "$yn" != "y" ]]
  7. then
  8. exit 0 # won't signal failure
  9. fi
  10. read -p "Enter new year (4 digits): " year
  11. read -p "Enter new month (2 digits): " month
  12. echo "This will modify files in examples/ and commit them to the current branch."
  13. read -p "Is that ok? (y/N): " yn
  14. if [[ "$yn" != "y" ]]
  15. then
  16. echo "Aborting."
  17. exit 1
  18. fi
  19. find examples -type f \( -name '*.html' -o -name '*.json' \) -print0 \
  20. | xargs -0 sed -i '' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]/$year-$month/g"
  21. # build the commit
  22. git add examples
  23. git commit --quiet -m "updated example dates"
  24. echo "Success."