From b06f2b1a1c22c1a668823a1f4b236283f7e8678b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Sat, 29 Oct 2022 14:16:07 +0200 Subject: [PATCH] Check to be in Isidore project. --- isidore.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/isidore.sh b/isidore.sh index 249cd7e..125817f 100755 --- a/isidore.sh +++ b/isidore.sh @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +ISIDORE_VERSION="0.1.0" ISIDORE_CONFIG_DIR="" ISIDORE_CONFIG_DIR_OPTIONS=( "$XDG_CONFIG_HOME/isidore" @@ -75,6 +76,18 @@ function print_usage() echo "USAGE: $1 [options]" } +## +# Check to see if at the root of an Isidore project. +## +function check_in_project() +{ + if ! [ -f "./config.php" ] || ! [ -f "./.isidore-version" ] + then + echo "ERROR: You are not currently in the root of an Isidore project." + exit 1 + fi +} + ## # Create a new project. # @@ -94,6 +107,7 @@ function new_project() \$site_name = \"$NEW_PROJECT_NAME\"; \$author = \"$ISIDORE_AUTHOR_NAME\"; ?>" >> $NEW_PROJECT_DIR/config.php + echo "$ISIDORE_VERSION" > $NEW_PROJECT_DIR/.isidore-version } ## @@ -101,8 +115,11 @@ function new_project() ## function clean_project() { - # TODO: Ensure that this is within an Isidore project. - rm -r output/ + check_in_project + if [ -d "./output/" ] + then + rm -r ./output/ + fi echo "Project cleaned." }