Skip to content

Commit

Permalink
Add yarn (#3432)
Browse files Browse the repository at this point in the history
* add yarn.lock

* fix comment

* remove yarn test

* add test

* fix test

* try fix again

* try 3rd time

* check filename and firstline for yarn lockfile
  • Loading branch information
sunderls authored and brandonblack committed Jan 23, 2017
1 parent 625b06c commit b36ea7a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/linguist/generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def generated?
generated_jflex? ||
generated_grammarkit? ||
generated_roxygen2? ||
generated_jison?
generated_jison? ||
generated_yarn_lock?
end

# Internal: Is the blob an Xcode file?
Expand Down Expand Up @@ -479,5 +480,13 @@ def generated_jison?
return lines[0].start_with?("/* parser generated by jison ") ||
lines[0].start_with?("/* generated by jison-lex ")
end

# Internal: Is the blob a generated yarn lockfile?
#
# Returns true or false.
def generated_yarn_lock?
return false unless name.match(/yarn\.lock/)
return lines[0].include?("# THIS IS AN AUTOGENERATED FILE")
end
end
end
9 changes: 9 additions & 0 deletions test/fixtures/Data/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
abab@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d"

abbrev@1, [email protected]:
version "1.0.9"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
3 changes: 3 additions & 0 deletions test/test_generated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def test_check_generated
generated_fixture_loading_data("Data/sourcemap.v3.map")
generated_fixture_loading_data("Data/sourcemap.v1.map")

# Yarn locfile
generated_fixture_loading_data("Data/yarn.lock")

# Specflow
generated_fixture_without_loading_data("Features/BindingCulture.feature.cs")

Expand Down

0 comments on commit b36ea7a

Please sign in to comment.