From 5719cc5dc902ce30b2e5781a279bdf140ccf0be3 Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Sat, 15 Aug 2015 05:43:50 -0400 Subject: [PATCH] Update site script and remove %site symbolic link Refactored and cleaned up site build script. Use cabal to run executable instead of through the link %site. Added options for running cabal commands clean, configure, and build via options clear, configure, and make respectively. These different names were used as to not reuse ones already in use by the hakyll generated site binary. Update deploy code in src/site.hs as there is no need to remove empty files anymore as they are no longer generated. Signed-off-by: Collin J. Doering --- %site | 1 - site | 52 +++++++++++++++++++++++++++++++++------------------- src/site.hs | 4 +--- 3 files changed, 34 insertions(+), 23 deletions(-) delete mode 120000 %site diff --git a/%site b/%site deleted file mode 120000 index a7c0769..0000000 --- a/%site +++ /dev/null @@ -1 +0,0 @@ -dist/build/blog-rekahsoft-ca/blog-rekahsoft-ca \ No newline at end of file diff --git a/site b/site index 042fb8f..6364bca 100755 --- a/site +++ b/site @@ -1,23 +1,37 @@ #!/bin/bash -if [ "$1" == "test" ]; then - if [ "$2" == "-s" ] || [ "$2" == "--run-selenium" ]; then - if ! type selenium &> /dev/null; then - echo "Failed to run Selenium. It must not be installed or not accessible on \$PATH!" - exit 1 +CABAL="/usr/bin/cabal" +CONFIGURE_SITE="configure --enable-tests" +BUILD_SITE="build" +RUN_SITE="run --verbose=0 blog-rekahsoft-ca" +TEST_SITE="test --show-details=always --test-option=--color" + +case "$1" in + test) + if [ "$2" == "-s" ] || [ "$2" == "--run-selenium" ]; then + if ! type selenium &> /dev/null; then + echo "Failed to run Selenium. It must not be installed or not accessible on \$PATH!" + exit 1 + fi + + echo "Running Selenium..." + selenium 2> /dev/null & + sleep 3s fi - echo "Running Selenium..." - selenium 2> /dev/null & - sleep 3s - fi - - # Remove empty files under directory _site - echo "Removing empty files..." - find _site -type f -empty -exec rm -v {} \; - - # Test site - cabal test --show-details=always --test-option=--color -else - exec "./%site" "$@" -fi + # Test site + $CABAL $TEST_SITE + ;; + clear) + $CABAL clean + ;; + configure) + $CABAL $CONFIGURE_SITE + ;; + make) + $CABAL $BUILD_SITE + ;; + *) + $CABAL $RUN_SITE "--" "$@" + ;; +esac diff --git a/src/site.hs b/src/site.hs index b2a3123..25845d1 100644 --- a/src/site.hs +++ b/src/site.hs @@ -91,9 +91,7 @@ pandocWriterOptions = defaultHakyllWriterOptions myConfig :: Configuration myConfig = defaultConfiguration - { deployCommand = "echo 'Removing empty files...' && " ++ - "find _site -type f -empty -exec rm -v {} \\; && " ++ - "echo '\nDeploying website...' && " ++ + { deployCommand = "echo '\nDeploying website...' && " ++ "rsync -rpogtzcv --delete -e ssh _site/ collin@rekahsoft.ca:~/public_html/blog/" , previewPort = 3000 }