check for dependencies before doing stuff

This commit is contained in:
CaptainArk 2018-04-19 23:16:51 +02:00
parent 7c343cd6b8
commit b5ec9eda3b
1 changed files with 8 additions and 8 deletions

View File

@ -13,6 +13,14 @@ GitHubApi="https://api.github.com/users/${UserName}/starred"
LastPage="$(curl -I ${GitHubApi} | grep -Eo 'page=[[:digit:]]+' | tail -n1)"
TempFile=$(mktemp -t github2email.sh.XXXXXXXXXX)
# Checking for dependencies
for Dependencies in curl jq r2e; do
if [[ ! -x $(which ${Dependencies}) ]]; then
echo "${Dependencies} is required to run to script. Exiting..."
exit 2
fi
done
for StarPages in $(seq 1 ${LastPage#*=}); do
curl -s "${GitHubApi}?page=${StarPages}" | jq -r '.[] | .name + "," + .html_url' | sed 's#$#/releases.atom#' >> ${TempFile}
done
@ -23,14 +31,6 @@ if [[ ! -s ${TempFile} ]]; then
exit 2
fi
# Checking for dependencies
for Dependencies in curl jq r2e; do
if [[ ! -x $(which ${Dependencies}) ]]; then
echo "${Dependencies} is required to run to script. Exiting..."
exit 2
fi
done
# Doing our magic stuff that does cool shit
for Star in $(cat ${TempFile}); do
ProjectName=${Star%,*}