Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added pre-fight check for compass to ensure it is an available command.

  • Loading branch information...
commit 7221e3e7af1ee3503c647e602ab2885e5bcc5eb1 1 parent 58c5411
@davidtucker authored
Showing with 28 additions and 2 deletions.
  1. +28 −2 generator/generateSenchaTouch2Project.sh
View
30 generator/generateSenchaTouch2Project.sh
@@ -102,6 +102,15 @@ OUTPUT_DIRECTORY=$(pwd)
##############
###
+# This function exits the running script and informs the user that the generator did not complete its tasks
+# as planned.
+###
+function exitOnError {
+ echo -e "\n${COLOR_RED}The generator DID NOT COMPLETE due to an error or misconfiguration. Please correct issue and rerun.${COLOR_RESET}"
+ exit 1
+}
+
+###
# This function is designed to handle much of the logic involved with asking the user for a value
# and then validating that value. It takes 4 parameters:
#
@@ -138,6 +147,20 @@ function getUserInput {
}
###
+# This function determines if compass is available on the command line (it has to be in the PATH). If it isn't
+# it calls the exitOnError function which exits the running script.
+###
+function doesCompassExist {
+ command -v compasss > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ echo -e "${COLOR_RED}You must have compass installed and accessible on the command line.${COLOR_RESET}"
+ echo -e "For more information, visit: http://compass-style.org/install/"
+ exitOnError
+ fi
+
+}
+
+###
# This function is designed to open a file from the template directory and create the same file in the
# output directory while also substituting in values for template variables. The available template
# variables are defined below:
@@ -272,11 +295,11 @@ function awaitEnterKey {
###
function validateTemplatesDirectory {
if [[ -f "$SENCHA_TEMPLATE_DIRECTORY/index.html" && -f "$SENCHA_TEMPLATE_DIRECTORY/app.js" ]]; then
- echo -e "${COLOR_BLUE}The Templates Directory is valid.${COLOR_RESET}\n\n"
+ echo -e "${COLOR_BLUE}Templates Directory is valid.${COLOR_RESET}\n\n"
return 0
else
echo "${COLOR_RED}The template directory is not valid - it does not contain an index.html and app.js file.${COLOR_RESET}"
- exit 0
+ exitOnError
fi
}
@@ -319,6 +342,9 @@ echo "Output Path: $OUTPUT_DIRECTORY"
# Validate templates directory
validateTemplatesDirectory
+# Check if compass is installed
+doesCompassExist
+
# Confirm with the user that they want to continue
askForUserConfirmation "Do you want to proceed?"
if [ $USER_CONFIRMATION_VALUE == "n" ]; then
Please sign in to comment.
Something went wrong with that request. Please try again.