Skip to content

Commit 05fed1f

Browse files
committed
improve package.json handling
1 parent 7dfa291 commit 05fed1f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

release.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ case $update in
9292
;;
9393
esac
9494

95+
pkg=$([[ -f package.json ]] && grep -q "\"version\":" package.json && echo true || echo false)
96+
9597
# inform about changes and ask to continue
9698
banner
9799
printf "\n\n Current Branch: $([[ "$branch" = "main" || "$branch" = "master" ]] && echo "$g" || echo "$r")${b}${branch}${x}"
98100
printf "\n\n Latest Version: $([[ "$latest" = "v0.0.0" ]] && echo "${r}${b}N/A${x}" || echo "${b}${latest}${x}")"
99101
printf "\n\n New Version: ${y}${b}${new}${x}"
100102
printf "\n\nContinue to create the version tag and push it to the git remote."
101-
[[ -f package.json ]] && printf "\nThe version field in the package.json will be updated and committed."
103+
$pkg && printf "\nThe version field in the package.json will be updated and committed."
102104
printf "\n\n${gr}(press ANY KEY to continue or ESCAPE to cancel)${x}\n"
103105
read -rsn1 key
104106

@@ -119,7 +121,7 @@ message="Release ${new}"
119121
set -e
120122

121123
# update and commit package.json if present
122-
if [[ -f package.json ]]; then
124+
if $pkg; then
123125
xsed "s/(\"version\":[[:space:]]*\")(.+)(\")/\1${new}\3/g" package.json
124126
git add package.json
125127
git commit -m "$message"

0 commit comments

Comments
 (0)