mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 21:31:01 +00:00
Detect generated source maps
This commit is contained in:
@@ -58,6 +58,7 @@ module Linguist
|
|||||||
godeps? ||
|
godeps? ||
|
||||||
generated_by_zephir? ||
|
generated_by_zephir? ||
|
||||||
minified_files? ||
|
minified_files? ||
|
||||||
|
source_map? ||
|
||||||
compiled_coffeescript? ||
|
compiled_coffeescript? ||
|
||||||
generated_parser? ||
|
generated_parser? ||
|
||||||
generated_net_docfile? ||
|
generated_net_docfile? ||
|
||||||
@@ -96,6 +97,20 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Internal: Is the blob a generated source map?
|
||||||
|
#
|
||||||
|
# Source Maps usually have .css.map or .js.map extensions. In case they
|
||||||
|
# are not following the name convention, detect them based on the content.
|
||||||
|
#
|
||||||
|
# Returns true or false.
|
||||||
|
def source_map?
|
||||||
|
return false unless extname.downcase == '.map'
|
||||||
|
|
||||||
|
name =~ /(\.css|\.js)\.map$/i || # Name convention
|
||||||
|
lines[0] =~ /^{"version":\d+,/ || # Revision 2 and later begin with the version number
|
||||||
|
lines[0] =~ /^\/\*\* Begin line maps\. \*\*\/{/ # Revision 1 begins with a magic comment
|
||||||
|
end
|
||||||
|
|
||||||
# Internal: Is the blob of JS generated by CoffeeScript?
|
# Internal: Is the blob of JS generated by CoffeeScript?
|
||||||
#
|
#
|
||||||
# CoffeeScript is meant to output JS that would be difficult to
|
# CoffeeScript is meant to output JS that would be difficult to
|
||||||
|
|||||||
Reference in New Issue
Block a user