update-example-dates.sh 672 B

12345678910111213141516171819202122232425262728
  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 "Enter new year (4 digits): " year
  6. read -p "Enter new month (2 digits): " month
  7. echo "This will modify files in examples/ and commit them to the current branch."
  8. read -p "Is that ok? (y/N): " yn
  9. if [[ "$yn" != "y" ]]
  10. then
  11. echo "Aborting."
  12. exit 1
  13. fi
  14. find examples -type f \( -name '*.html' -o -name '*.json' \) -print0 \
  15. | xargs -0 sed -i '' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]/$year-$month/g"
  16. # build the commit
  17. git add examples
  18. git commit --quiet -m "updated example dates"
  19. echo "Success."