lib/linguist/generated.rb in github-linguist-4.8.4 vs lib/linguist/generated.rb in github-linguist-4.8.5
- old
+ new
@@ -57,10 +57,11 @@
composer_lock? ||
node_modules? ||
godeps? ||
generated_by_zephir? ||
minified_files? ||
+ has_source_map? ||
source_map? ||
compiled_coffeescript? ||
generated_parser? ||
generated_net_docfile? ||
generated_postscript? ||
@@ -100,9 +101,24 @@
if lines.any?
(lines.inject(0) { |n, l| n += l.length } / lines.length) > 110
else
false
end
+ end
+
+ # Internal: Does the blob contain a source map reference?
+ #
+ # We assume that if one of the last 2 lines starts with a source map
+ # reference, then the current file was generated from other files.
+ #
+ # We use the last 2 lines because the last line might be empty.
+ #
+ # We only handle JavaScript, no CSS support yet.
+ #
+ # Returns true or false.
+ def has_source_map?
+ return false unless extname.downcase == '.js'
+ lines.last(2).any? { |line| line.start_with?('//# sourceMappingURL') }
end
# Internal: Is the blob a generated source map?
#
# Source Maps usually have .css.map or .js.map extensions. In case they