From ef9485db4ebc676a98b631f3ac09db305705c320 Mon Sep 17 00:00:00 2001 From: Joshua B Date: Wed, 4 Aug 2021 10:12:13 -0600 Subject: [PATCH] feat: if package.json exists then will update it with new version too in ship.version (#15) --- bin/semver | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/semver b/bin/semver index 2bc3624..2a8ad2a 100755 --- a/bin/semver +++ b/bin/semver @@ -28,6 +28,17 @@ function bump_version_file { local newVersion=$( bump_patch "$publishingVersion") local versionFile=${2:-version.properties} updateVersionFile "$newVersion" "$publishingVersion" "$versionFile" "${3}" + update_package_json "$newVersion" +} + +# if package.json exists then update it with new version +# $1 - the new version +function update_package_json { + if [ -f package.json ]; then + sed -i.bak -e "s|\"version\":.*|\"version\": \"${1}\",|g" package.json && rm -- "package.json.bak" + # add it so it gets picked up in the push + git add package.json + fi } # Updates version.properties with given version, sets publishedVersion to the $VERSION