Skip to content

Commit

Permalink
Merge pull request #10 from codeclimate/strip-non-css-files-from-incl…
Browse files Browse the repository at this point in the history
…ude-paths

Strip out non-CSS files directly included in include_paths.
  • Loading branch information
fhwang committed Sep 18, 2015
2 parents d87cb0e + a40573e commit 6187fb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/cc/engine/csslint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def build_files_with_inclusions(inclusions)
if include_path =~ %r{/$}
Dir.glob("#{include_path}/**/*.css")
else
include_path
include_path if include_path =~ /\.css$/
end
end.flatten
end.flatten.compact
end

def csslint_xml
Expand Down
7 changes: 6 additions & 1 deletion spec/cc/engine/csslint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module Engine

describe "with include_paths" do
let(:engine_config) {
{"include_paths" => %w(included.css included_dir/)}
{"include_paths" => %w(included.css included_dir/ config.yml)}
}

before do
Expand All @@ -49,6 +49,7 @@ module Engine
create_source_file(
"included_dir/sub/sub/subdir/file.css", "img { }"
)
create_source_file("config.yml", "foo:\n bar: \"baz\"")
create_source_file("not_included.css", "a { outline: none; }")
end

Expand All @@ -72,6 +73,10 @@ module Engine
expect{ lint.run }.to \
output(/Don't use IDs in selectors./).to_stdout
end

it "only includes CSS files, even when a non-CSS file is directly included" do
expect{ lint.run }.not_to output(/config.yml/).to_stdout
end
end
end

Expand Down

0 comments on commit 6187fb6

Please sign in to comment.