From ccc99749633917d9ff1ebc56331356171804c99c Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Fri, 1 Mar 2024 00:06:14 -0800 Subject: [PATCH] Added in check for existing module --- tdd.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tdd.sh b/tdd.sh index 787889c..7c922c6 100755 --- a/tdd.sh +++ b/tdd.sh @@ -14,9 +14,25 @@ clear_cmake_cache () { rm -rf CMakeCache.txt CMakeFiles/ } +does_moule_exist () { + local basename="$1" + + if [ -d "tests/$basename"] || [ -d "src/$basename" ]; then + return 1 + else + return 0 + fi +} + add_new_module () { read -p "Enter the name of the module:" modname - + + if does_module_exist $modname; then + echo "Module already exists!" + echo "Exiting without changing anything" + exit + fi + modname_cap=$(echo $modname | sed 's/[a-z]/\U&/g') modsrc_dir="./src/${modname}" modtest_dir="./tests/${modname}" @@ -41,7 +57,6 @@ add_new_module () { # Now we add the new files to the git tracked files - del_module }