From 619d1f06957c0f205cf3eeabbbc944dbce1fc76d Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 29 Aug 2022 21:24:56 -0700 Subject: [PATCH] check if project dir already exists --- install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 706f351..64ef79e 100755 --- a/install.sh +++ b/install.sh @@ -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"