♻️ Refactored where dependency checks occur
This commit is contained in:
parent
d79e6bc218
commit
f5ee5d2fe4
1 changed files with 32 additions and 14 deletions
46
scripts/bgit
46
scripts/bgit
|
|
@ -16,21 +16,10 @@ txtyellow=${txtbld}$(tput setaf 3)
|
||||||
txtwhite=${txtbld}$(tput setaf 7)
|
txtwhite=${txtbld}$(tput setaf 7)
|
||||||
|
|
||||||
# Dependency check
|
# Dependency check
|
||||||
dependencies=("git" "node" "npm" "xclip")
|
if ! command -v git &> /dev/null
|
||||||
numdependencies=4
|
|
||||||
missingdependencies=0
|
|
||||||
for ((i = 0; i < numdependencies; i++)) ;
|
|
||||||
do
|
|
||||||
if ! command -v "${dependencies[$i]}" &> /dev/null
|
|
||||||
then
|
then
|
||||||
echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}"
|
echo "${txtred}dependency not met: git"
|
||||||
missingdependencies=$((missingdependencies+1))
|
echo "Please install needed depndencies${txtwhite}"
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $missingdependencies -gt 0 ] ;
|
|
||||||
then
|
|
||||||
echo "${txtred}Please install needed dependencies${txtwhite}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -59,6 +48,7 @@ if [ $numrepos -eq 0 ] ; then
|
||||||
break
|
break
|
||||||
elif [[ $init == "y" || $init == "yes" ]] ; then
|
elif [[ $init == "y" || $init == "yes" ]] ; then
|
||||||
|
|
||||||
|
|
||||||
# Creates a default README.md
|
# Creates a default README.md
|
||||||
echo -e "## A Simple README\n\nSome Text" > README.md
|
echo -e "## A Simple README\n\nSome Text" > README.md
|
||||||
# Creates a default .gitignore
|
# Creates a default .gitignore
|
||||||
|
|
@ -100,6 +90,25 @@ if [ $numrepos -eq 0 ] ; then
|
||||||
# initializes standard html/css/javascript project (incomplete)
|
# initializes standard html/css/javascript project (incomplete)
|
||||||
read -e -r -p "${txtwhite}would you like to make this an npm project?(y/n): ${txtyellow}" confirmnpm
|
read -e -r -p "${txtwhite}would you like to make this an npm project?(y/n): ${txtyellow}" confirmnpm
|
||||||
if [[ $confirmnpm == "y" || $confirmnpm == "yes" ]] ; then
|
if [[ $confirmnpm == "y" || $confirmnpm == "yes" ]] ; then
|
||||||
|
# Dependency check
|
||||||
|
dependencies=("node" "npm")
|
||||||
|
numdependencies=2
|
||||||
|
missingdependencies=0
|
||||||
|
for ((i = 0; i < numdependencies; i++)) ;
|
||||||
|
do
|
||||||
|
if ! command -v "${dependencies[$i]}" &> /dev/null
|
||||||
|
then
|
||||||
|
echo "${txtred}dependency not met: ${dependencies[$i]}${txtwhite}"
|
||||||
|
missingdependencies=$((missingdependencies+1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $missingdependencies -gt 0 ] ;
|
||||||
|
then
|
||||||
|
echo "${txtred}Please install needed dependencies${txtwhite}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
npm init -y
|
npm init -y
|
||||||
npm install -D nodemon prettier jest
|
npm install -D nodemon prettier jest
|
||||||
|
|
||||||
|
|
@ -190,6 +199,15 @@ if [ $numrepos -eq 0 ] ; then
|
||||||
source $HOME/.gh_pat
|
source $HOME/.gh_pat
|
||||||
|
|
||||||
if [[ $crepo == 'y' || $crepo == 'yes' ]] ; then
|
if [[ $crepo == 'y' || $crepo == 'yes' ]] ; then
|
||||||
|
|
||||||
|
# Dependency check
|
||||||
|
if ! command -v xclip &> /dev/null
|
||||||
|
then
|
||||||
|
echo "${txtred}dependency not met: xclip"
|
||||||
|
echo "Please install needed depndencies${txtwhite}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "${txtgreen}Host Site is github.com, creating repository...${txtwhite}"
|
echo "${txtgreen}Host Site is github.com, creating repository...${txtwhite}"
|
||||||
curl -u $uname:$GH_TOKEN https://api.github.com/user/repos -d '{"name": "'${repo}'"}'
|
curl -u $uname:$GH_TOKEN https://api.github.com/user/repos -d '{"name": "'${repo}'"}'
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue