Browse Source

add unused sass var warning to dev-precommit

Byron Jones 6 years ago
parent
commit
abbef93c71
1 changed files with 11 additions and 0 deletions
  1. 11 0
      dev-precommit

+ 11 - 0
dev-precommit

@@ -49,6 +49,7 @@ foreach my $file (glob('web/*.sass')) {
 
     my @original = split(/\n/, Mojo::File->new($file)->slurp());
     my @output;
+    my @variables;
     my $chunk = {};
 
     reset_chunk($chunk);
@@ -62,6 +63,10 @@ foreach my $file (glob('web/*.sass')) {
             next;
         }
 
+        if ($line =~ /^(\$[^:]+):.+$/) {
+            push @variables, $1;
+        }
+
         if ($indent != $chunk->{indent}) {
             push @output, process_chunk($chunk);
             $chunk->{indent} = $indent;
@@ -100,6 +105,12 @@ foreach my $file (glob('web/*.sass')) {
         say ' unchanged';
     }
     set_modified($file);
+
+    foreach my $var (@variables) {
+        my $count = 0;
+        $count++ while $output =~ /\Q$var\E/g;
+        say "\e[33munused sass variable: ", $var, "\e[0m" if $count == 1;
+    }
 }
 
 # tidy all the perl as per .perltidy