Sha256: ed903fc88bccd87f2347d9be4d961c640f2638b83f14caa545ab71a8af48da95

Contents?: true

Size: 868 Bytes

Versions: 18

Compression:

Stored size: 868 Bytes

Contents

#!/usr/bin/env bash
#
# Approach:
# 1. Find variable declaration in the form of "$my-var: anyvalue"
# 2. Loop through found variables and find occurrences of each variable in all sass files
# 3. Filter out vars that occurred only once
#
# Run from command line with `build/lint-vars.sh scss`.
#
# Source: https://gist.github.com/badsyntax/6193491

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 --color=never -h '^$[a-zA-Z0-9_-][^:]*' {} \; | sed 's/$\([a-zA-Z0-9_-][^:]*\).*/\1/')

for var in $vars; do
	echo -n "Occurrences of \"\$$var\":"
	find "$1" -type f -name "*.scss" -exec grep --color=never -h "$var" "{}" \; | wc -l
done | grep ' 1$'

Version data entries

18 entries across 16 versions & 2 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/bootstrap-css/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.4.3 spec/dummy/node_modules/bootstrap-css/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.4.2 spec/dummy/node_modules/bootstrap-css/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.3.35 spec/dummy/node_modules/maxivak-bootstrap-css/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.3.35 node_modules/maxivak-bootstrap-css/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.3.34 spec/dummy/node_modules/maxivak-bootstrap-css/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.3.34 node_modules/maxivak-bootstrap-css/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.3.30 spec/dummy/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.3.29 spec/dummy/node_modules/bootstrap/build/lint-vars.sh
optimacms-0.3.23 spec/dummy/node_modules/bootstrap/build/lint-vars.sh
card-1.93.7 mod/bootstrap/vendor/bootstrap/build/lint-vars.sh
card-1.93.6 mod/bootstrap/vendor/bootstrap/build/lint-vars.sh
card-1.93.5 mod/bootstrap/vendor/bootstrap/build/lint-vars.sh
card-1.93.4 mod/bootstrap/vendor/bootstrap/build/lint-vars.sh
card-1.93.3 mod/bootstrap/vendor/bootstrap/build/lint-vars.sh
card-1.93.2 mod/bootstrap/vendor/bootstrap/build/lint-vars.sh
card-1.93.1 mod/bootstrap/vendor/bootstrap/build/lint-vars.sh
optimacms-0.3.15 spec/dummy/node_modules/bootstrap/build/lint-vars.sh