@@ -10,7 +10,7 @@ set -o pipefail
1010# Stores the canonical version for the project.
1111VERSION_FILE=package.json
1212# Files that should be updated with the new version.
13- VERSION_FILES=(" $VERSION_FILE " )
13+ VERSION_FILES=(" $VERSION_FILE " package-lock.json )
1414
1515USAGE=$(
1616 cat << END_OF_LINE
@@ -32,7 +32,9 @@ END_OF_LINE
3232old_version=$( sed -n " s/^[[:blank:]]*\" version\" : \" \(.*\)\" ,\{0,1\}$/\1/p" $VERSION_FILE )
3333# Comment out periods so they are interpreted as periods and don't
3434# just match any character
35- old_version_regex=" ^\([[:blank:]]*\" version\" : \)\" ${old_version// \. / \\\. } \" "
35+ # We are not currently using this, but it will be necessary if we need to work with
36+ # non-npm files in the future.
37+ # old_version_regex="^\([[:blank:]]*\"version\": \)\"${old_version//\./\\\.}\""
3638new_version=" $old_version "
3739
3840bump_part=" "
@@ -154,15 +156,21 @@ if [ "$with_prerelease" = true ]; then
154156 new_version=" $temp_version "
155157fi
156158
157- tmp_file=/tmp/version.$$
158- for version_file in " ${VERSION_FILES[@]} " ; do
159- if [ ! -f " $version_file " ]; then
160- echo Missing expected file: " $version_file "
161- exit 1
162- fi
163- sed " s/$old_version_regex /\1\" $new_version \" /" " $version_file " > $tmp_file
164- mv $tmp_file " $version_file "
165- done
159+ # We are not currently using this, but it will be necessary if we need to work with
160+ # non-npm files in the future.
161+ # tmp_file=/tmp/version.$$
162+ # for version_file in "${VERSION_FILES[@]}"; do
163+ # if [ ! -f "$version_file" ]; then
164+ # echo Missing expected file: "$version_file"
165+ # exit 1
166+ # fi
167+ # sed "s/$old_version_regex/\1\"$new_version\"/" "$version_file" > $tmp_file
168+ # mv $tmp_file "$version_file"
169+ # done
170+
171+ # Use npm's built-in functionality to update the version of the package. We use the
172+ # `--no-git-tag-version` option to prevent npm from committing and creating a tag.
173+ npm version --no-git-tag-version " $new_version "
166174
167175git add " ${VERSION_FILES[@]} "
168176git commit --message " $commit_prefix version from $old_version to $new_version "
0 commit comments