Yuicompress

From Attie's Wiki
(Difference between revisions)
Jump to: navigation, search
m (Created page with 'Use the following code with Yahoo's YUIcompressor <source lang="bash"> #!/bin/bash if [ "$#" == "0" ]; then echo "Usage: $# file1 [file2 ...]" exit 1 fi while (( "$#" )); do…')
 
m
 
Line 4: Line 4:
 
#!/bin/bash
 
#!/bin/bash
 
if [ "$#" == "0" ]; then
 
if [ "$#" == "0" ]; then
   echo "Usage: $# file1 [file2 ...]"
+
   echo "Usage: $0 file1 [file2 ...]"
 
   exit 1
 
   exit 1
 
fi
 
fi

Latest revision as of 11:20, 19 September 2011

Use the following code with Yahoo's YUIcompressor

#!/bin/bash
if [ "$#" == "0" ]; then
  echo "Usage: $0 file1 [file2 ...]"
  exit 1
fi
while (( "$#" )); do
  TYPE=`echo $1 | awk -F . '{print $NF}'`
  echo -n "($TYPE) $1..."
  cat "$1" | java -jar yuicompressor-2.4.2.jar --type $TYPE > "$1.min"
  if [ "$?" == "1" ]; then
    echo "YUI Error"
    exit 1
  fi
  echo -n " >> `echo $1.min | awk -F / '{print $NF}'`"
  gzip -c "$1.min" > "$1.gz"
  if [ "$?" == "1" ]; then
    echo "GZip Error"
    exit 1
  fi
  rm "$1.min"
  echo " >> `echo $1.gz | awk -F / '{print $NF}'`"
  shift
done
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox