Sha256: 48133af44759d3bdc75bdf15d3e3b1894d08c81e82f9eade5be96a72a989ae25

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 Bytes

Contents

#!/usr/bin/env bash
#
# Updates the *.gemspec in the current directory to use the latest releases of gems
#
set -uf -o pipefail
IFS=$'\n'

gemspec=$(find . -type f -maxdepth 1 -name "*.gemspec")
add_dependency_lines=$(cat ${gemspec} | grep "s.add_dependency '[^']*', '")
if [ $? -ne 0 ]; then
  # No add_dependency_lines found - nothing to do
  exit 0
fi

set -e

gems=$(echo "${add_dependency_lines}" | tr -s ' ' | cut -d ' ' -f3 | cut -d"'" -f 2)
while read -r gem; do
  gem_line=$(gem list "${gem}" --remote --all --no-prerelease | grep "${gem}")
  latest_version=$(echo "${gem_line}" | cut -d'(' -f2 | cut -d',' -f1)
  cat "${gemspec}" | sed "s/s.add_dependency '${gem}', .*/s.add_dependency '${gem}', '~> ${latest_version}'/" > ${gemspec}.tmp
  mv ${gemspec}.tmp ${gemspec}
done <<< "${gems}"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-expressions-8.0.0 scripts/update-gemspec