#!/bin/bash

pushd `dirname $0` > /dev/null
BASE_DIR=`pwd`
popd > /dev/null
BASE_DIR=`dirname "$BASE_DIR"` 


. "${BASE_DIR}"/conf/startup.properties

CP=.$(find -L "$LIB" -type d -exec printf ":{}/*" \;) 

export CLASSPATH=$CP

if [ $# -ne 1 ]
then
        echo This script requires one argument: a path to a theme directory, containing a 'styles.scss' file.
        exit 1 
fi

if [ ! -f "$1/styles.scss" ]
then
        echo There is no styles.scss file under the given path: $1
        exit 2
fi


$JAVA ${MEM} ${OPTS} ${DEFS} com.vaadin.sass.SassCompiler "$1/styles.scss" "$1/styles.css"

if [ -f "$1/styles.css" ]
then
        echo Successfully generated $1/styles.css 
else
        echo ERROR $1/styles.css was not generated
fi
