From b36ea7ac9d07e4af166a052ec97fdcadbcea4b3d Mon Sep 17 00:00:00 2001 From: sunderls Date: Tue, 24 Jan 2017 03:58:53 +0900 Subject: [PATCH] Add yarn (#3432) * 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 --- lib/linguist/generated.rb | 11 ++++++++++- test/fixtures/Data/yarn.lock | 9 +++++++++ test/test_generated.rb | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/Data/yarn.lock diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index edd3b37a..fce3ab4b 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -80,7 +80,8 @@ module Linguist generated_jflex? || generated_grammarkit? || generated_roxygen2? || - generated_jison? + generated_jison? || + generated_yarn_lock? end # Internal: Is the blob an Xcode file? @@ -479,5 +480,13 @@ module Linguist 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 diff --git a/test/fixtures/Data/yarn.lock b/test/fixtures/Data/yarn.lock new file mode 100644 index 00000000..014e8983 --- /dev/null +++ b/test/fixtures/Data/yarn.lock @@ -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, abbrev@1.0.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" diff --git a/test/test_generated.rb b/test/test_generated.rb index 6301d971..d12108d7 100644 --- a/test/test_generated.rb +++ b/test/test_generated.rb @@ -79,6 +79,9 @@ class TestGenerated < Minitest::Test 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")