mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	Fix for interpreters not getting add to samples.json
This commit is contained in:
		@@ -52,14 +52,16 @@ module Linguist
 | 
				
			|||||||
              })
 | 
					              })
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
          else
 | 
					          else
 | 
				
			||||||
 | 
					            path = File.join(dirname, filename)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if File.extname(filename) == ""
 | 
					            if File.extname(filename) == ""
 | 
				
			||||||
              raise "#{File.join(dirname, filename)} is missing an extension, maybe it belongs in filenames/ subdir"
 | 
					              raise "#{path} is missing an extension, maybe it belongs in filenames/ subdir"
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            yield({
 | 
					            yield({
 | 
				
			||||||
              :path     => File.join(dirname, filename),
 | 
					              :path     => path,
 | 
				
			||||||
              :language => category,
 | 
					              :language => category,
 | 
				
			||||||
              :interpreter => File.exist?(filename) ? Linguist.interpreter_from_shebang(File.read(filename)) : nil,
 | 
					              :interpreter => Linguist.interpreter_from_shebang(File.read(path)),
 | 
				
			||||||
              :extname  => File.extname(filename)
 | 
					              :extname  => File.extname(filename)
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,7 @@ class TestSamples < Test::Unit::TestCase
 | 
				
			|||||||
    assert_equal data['languages_total'], data['languages'].inject(0) { |n, (_, c)| n += c }
 | 
					    assert_equal data['languages_total'], data['languages'].inject(0) { |n, (_, c)| n += c }
 | 
				
			||||||
    assert_equal data['tokens_total'], data['language_tokens'].inject(0) { |n, (_, c)| n += c }
 | 
					    assert_equal data['tokens_total'], data['language_tokens'].inject(0) { |n, (_, c)| n += c }
 | 
				
			||||||
    assert_equal data['tokens_total'], data['tokens'].inject(0) { |n, (_, ts)| n += ts.inject(0) { |m, (_, c)| m += c } }
 | 
					    assert_equal data['tokens_total'], data['tokens'].inject(0) { |n, (_, ts)| n += ts.inject(0) { |m, (_, c)| m += c } }
 | 
				
			||||||
 | 
					    assert !data["interpreters"].empty?
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  # Check that there aren't samples with extensions that aren't explicitly defined in languages.yml
 | 
					  # Check that there aren't samples with extensions that aren't explicitly defined in languages.yml
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user