From 3e606600711016715733ef81a2b2ba1d1224ee4e Mon Sep 17 00:00:00 2001 From: jakeg00dwin Date: Fri, 1 Mar 2024 00:55:06 -0800 Subject: [PATCH] fixed up the script so it correctly outputs the template files to hte tests dir and the src dir --- tdd.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tdd.sh b/tdd.sh index 7c922c6..c73cbba 100755 --- a/tdd.sh +++ b/tdd.sh @@ -14,20 +14,22 @@ clear_cmake_cache () { rm -rf CMakeCache.txt CMakeFiles/ } -does_moule_exist () { +does_module_exist () { local basename="$1" - if [ -d "tests/$basename"] || [ -d "src/$basename" ]; then - return 1 + if [ -d "src/${basename}" ]; then + echo "1" else - return 0 + echo "0" fi } add_new_module () { read -p "Enter the name of the module:" modname + + result=$(does_module_exist "$modname") - if does_module_exist $modname; then + if [ "${result}" -eq "1" ]; then echo "Module already exists!" echo "Exiting without changing anything" exit @@ -48,8 +50,8 @@ add_new_module () { sed "s/module_name/${modname_cap}/" $MODULE_DIR/module_name.h > $modsrc_dir/${modname}.h sed "s/module_name/${modname}/" $MODULE_DIR/CMakeLists.txt > $modsrc_dir/CMakeLists.txt - sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.c > $modsrc_dir/test_${modname}.c - sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modsrc_dir/CMakeLists.txt + sed "s/module_name/${modname}/" $MODULE_DIR/test_module_name.c > $modtest_dir/test_${modname}.c + sed "s/module_name/${modname}/" $MODULE_DIR/TestCMakeLists.txt > $modtest_dir/CMakeLists.txt echo "Resulting files/dirs:" tree -L 2 $modsrc_dir @@ -57,7 +59,7 @@ add_new_module () { # Now we add the new files to the git tracked files - del_module + #del_module } del_module () {