check if project dir already exists

cosmonaut 2022-08-29 21:24:56 -07:00
parent eec3c9f10a
commit 619d1f0695
1 changed files with 9 additions and 3 deletions

View File

@ -63,15 +63,21 @@ function getLibs()
fi
}
getLibs
read -p "Enter your project name or 'exit' to quit: " newProjectName
if [[ $newProjectName = 'exit' || -z "$newProjectName" ]]; then
exit 1
fi
# copy everything into new dir
NEW_PROJECT_DIR="$MY_DIR/../$newProjectName"
if [ -d "$NEW_PROJECT_DIR" ]; then
>&2 echo "ERROR: Project directory already exists."
exit 1
fi
getLibs
# copy everything into new dir
cp -R "$MY_DIR" "$NEW_PROJECT_DIR"
cd "$NEW_PROJECT_DIR"