@@ -10,6 +10,8 @@ module Engine
|
10 | 10 | DEFAULT_IDENTIFIER = OpenStruct.new(value: "parse-error")
|
11 | 11 |
|
12 | 12 | class CSSlint
|
| 13 | +DEFAULT_EXTENSIONS = [".css"].freeze |
| 14 | + |
13 | 15 | autoload :CheckDetails, "cc/engine/csslint/check_details"
|
14 | 16 |
|
15 | 17 | def initialize(directory: , io: , engine_config: )
|
@@ -33,6 +35,8 @@ def run
|
33 | 35 |
|
34 | 36 | private
|
35 | 37 |
|
| 38 | +attr_reader :engine_config |
| 39 | + |
36 | 40 | # rubocop:disable Metrics/MethodLength
|
37 | 41 | def create_issue(node, path)
|
38 | 42 | check_name = node.attributes.fetch("identifier", DEFAULT_IDENTIFIER).value
|
@@ -72,14 +76,16 @@ def csslint_xml
|
72 | 76 | end
|
73 | 77 |
|
74 | 78 | def files_to_inspect
|
75 |
| -include_paths = @engine_config["include_paths"] || ["./"] |
76 |
| -include_paths.each_with_object([]) do |path, out| |
| 79 | +include_paths = engine_config.fetch("include_paths", ["./"]) |
| 80 | +extensions = engine_config.fetch("extensions", DEFAULT_EXTENSIONS) |
| 81 | +extensions_glob = extensions.join(",") |
| 82 | +include_paths.flat_map do |path| |
77 | 83 | if path.end_with?("/")
|
78 |
| -out.concat(Dir.glob("#{path}**/*.css")) |
79 |
| -elsif path.end_with?(".css") |
80 |
| -out << path |
| 84 | +Dir.glob("#{File.expand_path path}/**/*{#{extensions_glob}}") |
| 85 | +elsif path.end_with?(*extensions) |
| 86 | +path |
81 | 87 | end
|
82 |
| -end |
| 88 | +end.compact |
83 | 89 | end
|
84 | 90 | end
|
85 | 91 | end
|
|
0 commit comments