@@ -12,27 +12,25 @@ BY="\033[1;33m" # bright yellow
1212BG=" \033[1;92m" # bright green
1313BW=" \033[1;97m" # bright white
1414
15- # Validate version arg
16- ver_types=(" major" " minor" " patch" )
17- if [[ ! " ${ver_types[@]} " =~ " $1 " ]] ; then
18- echo " ${BR} Invalid version argument. Please specify 'major', 'minor', or 'patch'.${NC} "
19- exit 1 ; fi
20-
21- # PULL latest changes
22- echo -e " ${BY} Pulling latest changes from remote to sync local repository...${NC} \n"
23- git pull || (echo -e " ${BR} Merge failed, please resolve conflicts!${NC} " && exit 1)
24- echo ' '
25-
2615# Determine new version to bump to
16+ BUMP_TYPES=(" major" " minor" " patch" )
2717old_ver=$( node -pe " require('./package.json').version" )
2818IFS=' .' read -ra subvers <<< " $old_ver" # split old_ver into subvers array
2919case $1 in # edit subvers based on version type
3020 " patch" ) subvers[2]=$(( subvers[2 ] + 1 )) ;;
3121 " minor" ) subvers[1]=$(( subvers[1 ] + 1 )) ; subvers[2]=0 ;;
3222 " major" ) subvers[0]=$(( subvers[0 ] + 1 )) ; subvers[1]=0 ; subvers[2]=0 ;;
23+ * ) echo -e " \n${BR} Invalid bump type arg provided: $1 ${NC} " ;
24+ echo -e " \n${BY} Valid args are: ${BUMP_TYPES[*]/#/ --}${NC} " ;
25+ exit 1 ;;
3326esac
3427NEW_VER=$( printf " %s.%s.%s" " ${subvers[@]} " )
3528
29+ # PULL latest changes
30+ echo -e " ${BY} Pulling latest changes from remote to sync local repository...${NC} \n"
31+ git pull || (echo -e " ${BR} Merge failed, please resolve conflicts!${NC} " && exit 1)
32+ echo ' '
33+
3634# Bump version in package.json + package-lock.json
3735echo -e " ${BY} Bumping versions in package manifests...${BW} "
3836npm version --no-git-tag-version " $NEW_VER "
0 commit comments