2
0

update-demo-dates.sh 653 B

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