update_version.sh 515 B

1234567891011121314151617
  1. #!/bin/bash
  2. # Usage: ./update_version.sh <new_version>
  3. # FORMAT IS <0.0.0>
  4. if [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  5. find . -name 'package.json' -not -path '*/node_modules/*' -exec bash -c '
  6. # Parse the version from package.json
  7. current_version=$(grep -o "\"version\": \"[^\"]*" "$0" | cut -d"\"" -f4)
  8. # Update the version
  9. perl -i -pe"s/$current_version/'$1'/" "$0"
  10. ' {} \;
  11. echo "Updated versions to $1";
  12. else
  13. echo "Version format <$1> isn't correct, proper format is <0.0.0>";
  14. fi