Skip to content

Commit

Permalink
feat: trap ctrl_c to show result
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentHardouin committed Mar 30, 2022
1 parent df34525 commit 2b81136
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions npm-bump
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ declare -a new_version_packages
declare -a no_updated_packages
markdown=0

trap ctrl_c INT

function ctrl_c() {
show_result
}

function transform_exclude_package_names() {
IFS=',' read -r -a array <<< "$exclude"
join="";
Expand Down Expand Up @@ -136,18 +142,22 @@ function npm_files_exist() {
fi
}

function show_result() {
if [ ${#updated_packages[@]} -eq 0 ]; then
printf "%s\n" "No package updated"
else
printf "\n"
if [ $markdown -eq 0 ]; then
show_updated_packages
else
show_updated_packages_in_markdown
fi
printf "\n"
show_no_updated_package
fi
}

handle_arguments "$@"
npm_files_exist
bump_version
if [ ${#updated_packages[@]} -eq 0 ]; then
printf "%s\n" "No package updated"
else
printf "\n"
if [ $markdown -eq 0 ]; then
show_updated_packages
else
show_updated_packages_in_markdown
fi
printf "\n"
show_no_updated_package
fi
show_result

0 comments on commit 2b81136

Please sign in to comment.