Skip to content

Instantly share code, notes, and snippets.

@mariofink
Created May 3, 2014 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariofink/12d3df1fb918e1d16a79 to your computer and use it in GitHub Desktop.
Save mariofink/12d3df1fb918e1d16a79 to your computer and use it in GitHub Desktop.
SASS Variable Usage
#! /usr/bin/env bash
#
# checks how many times SASS variables have been used inside a project
#
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 "Checking SASS variable usage. 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 ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment