Created
May 3, 2014 15:27
-
-
Save mariofink/3dbeb9e206933885bab8 to your computer and use it in GitHub Desktop.
SASS Find unused variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# | |
# checks your scss files for unused variables | |
# | |
if [ -z "$1" ]; then | |
echo "Please specify a directory as the first argument." | |
exit 1 | |
fi | |
if [ ! -d "$1" ]; then | |
echo "Not a valid directory." | |
exit 1 | |
fi | |
echo "Finding unused variables. This might take some time..." | |
vars=`find "$1" -type f -name "*.scss" -exec grep -h '^$[a-z_][^:]*' {} \; | sed 's/$\([a-z_][^:]*\).*/\1/'` | |
for var in $vars; do | |
echo -n "\$"$var; | |
find "$1" -type f -name "*.scss" -exec grep -h "$var" {} \; | wc -l | |
done | grep ' 1$' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment