#!/bin/bash # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Check args [ $# -lt 1 ] && echo "Not enough arguments" && exit 1 args="$@" start_dir="$(pwd)" for a in $args do [ ! -d "$a" ] && echo "=> skipping \"$a\": not a directory" && continue echo "=> entering \"$a\"" cd $a # Check we can use or create style and script dirs for d in style script do if [ ! -d $d -a -e $d ]; then echo "$d exists but is not a directory" exit 1 fi done # Clean for f in style/*.css; do [ -e "$f" -a ! -d "$f" ] && rm "$f"; done for f in script/*.js; do [ -e "$f" -a ! -d "$f" ] && rm "$f"; done # Generate style sheets i=0 for d in style/src/*.css do [ ! -d "$d" ] && continue css="$(ls "$d" | grep -E '\.css$')" ccss="$(ls "$d" | grep -E '\.ccss$')" [ "$css" == "" -a "$ccss" == "" ] && continue let i++ f="$(basename $d)" dest="style/$f" echo "creating \"$f\"" [ $i -eq 1 -a ! -d style ] && mkdir style touch "$dest" for f in $css; do cat "$d/$f" >>"$dest"; echo -e "\n\n" >>"$dest"; done for f in $ccss; do clevercss < "$d/$f" >>"$dest"; echo -e "\n\n" >>"$dest"; done done [ $i -eq 0 ] && echo "No style found" # Generate scripts i=0 for d in script/src/*.js do [ ! -d "$d" ] && continue js="$(ls "$d" | grep -E '\.js$')" [ "$js" == "" ] && continue let i++ f="$(basename $d)" dest="script/$f" echo "creating \"$f\"" [ $i -eq 1 -a ! -d script ] && mkdir script touch "$dest" for f in $js; do cat "$d/$f" >>"$dest"; echo -e "\n\n" >>"$dest"; done done [ $i -eq 0 ] && echo "No script found" cd "$start_dir" done exit 0