mystix
6/5/2010 - 4:36 PM

JavaScript cleanup script

JavaScript cleanup script

#!/bin/bash

if [ $# -lt 1 ]; then
    echo "Usage: $0 FILENAME"
    exit 1
fi

# 1) convert file to unix line endings
# 2) converts tab characters to 4 spaces
# 3) collapse multi-line c-style comments, then strip them from source
# 4) trim trailing whitespace
#
# note: this script requires the reccoms.sh script as well
dos2unix < $1 | expand -t4 | ./remccoms.sh | sed 's/[ \t]*$//' > $1.tmp
mv $1.tmp $1