Add bun and deno to interpreters in languages.yml for JavaScript#7878
Add bun and deno to interpreters in languages.yml for JavaScript#7878oopsio wants to merge 16 commits intogithub-linguist:mainfrom
bun and deno to interpreters in languages.yml for JavaScript#7878Conversation
bun and deno to interpreters in languages.yml
bun and deno to interpreters in languages.ymlbun and deno to interpreters in languages.yml for JavaScript
| def test_find_by_interpreter | ||
| { | ||
| "bun" => "JavaScript", | ||
| "deno" => "JavaScript", |
There was a problem hiding this comment.
🤔 this is ignoring these two are already associated with TypeScript:
linguist/lib/linguist/languages.yml
Lines 8029 to 8039 in 537297c
There was a problem hiding this comment.
I wasn't thinking about removing it, I was thinking about changing it into an array with both languages.
If you'd run the tests you'd have seen it fail with this:
TestLanguage#test_find_by_interpreter [test/test_language.rb:222]:
--- expected
+++ actual
@@ -1 +1 @@
-[#<Linguist::Language name=JavaScript>]
+[#<Linguist::Language name=JavaScript>, #<Linguist::Language name=TypeScript>]
However now I look at the test code, this would also require an update to the test as it isn't expecting more than one language with the same interpreter.
This change would be required too:
--- test/test_language.rb
+++ test/test_language.rb
@@ -217,7 +217,8 @@ def test_find_by_interpreter
"sbcl" => "Common Lisp",
"sclang" => "SuperCollider"
}.each do |interpreter, language|
- assert_equal [Language[language]], Language.find_by_interpreter(interpreter)
+ languages = Array(language).map { |lang| Language[lang] }
+ assert_equal languages, Language.find_by_interpreter(interpreter)
end
assert_equal [], Language.find_by_interpreter(nil)So if we put both together, please make this change:
--- test/test_language.rb
+++ test/test_language.rb
@@ -207,6 +207,8 @@ def test_find_by_filename
def test_find_by_interpreter
{
+ "bun" => ["JavaScript", "TypeScript"],
+ "deno" => ["JavaScript", "TypeScript"],
"ruby" => "Ruby",
"Rscript" => "R",
"sh" => "Shell",
@@ -217,7 +219,8 @@ def test_find_by_interpreter
"sbcl" => "Common Lisp",
"sclang" => "SuperCollider"
}.each do |interpreter, language|
- assert_equal [Language[language]], Language.find_by_interpreter(interpreter)
+ languages = Array(language).map { |lang| Language[lang] }
+ assert_equal languages, Language.find_by_interpreter(interpreter)
end
assert_equal [], Language.find_by_interpreter(nil)There was a problem hiding this comment.
I have added the changes, it adds the changes you required me to and added samples of Deno and Bun with the shebangs. Also, a question, can linguist handle multiple arguments of shebang's? (example: if i have #!/usr/bin/env -S deno run, does it detect the deno interpreter?.) Let me know!
There was a problem hiding this comment.
Also, a question, can linguist handle multiple arguments of shebang's? (example: if i have #!/usr/bin/env -S deno run, does it detect the
denointerpreter?.) Let me know!
Yup:
linguist/lib/linguist/shebang.rb
Lines 41 to 49 in 537297c
…th the `TypeScript` language. Removed JavaScript entries from interpreter test.
lildude
left a comment
There was a problem hiding this comment.
Along with my inline comment, you've got test failures due to the extensionless test/fixtures/TypeScript/main test file. I've searched GitHub and there are only 2 other users of this that are not Linguist and it's forks.
With that in mind, please:
- remove that file
- add real-world samples for both JavaScript and TypeScript which have bun and deno shebangs into their respective
samples/directories.
…reter for the `JavaScript` language.
…guist/blob/main/test/test_language.rb) handle array's of languages for each interpreter in `test_find_by_interpreter`.
lildude
left a comment
There was a problem hiding this comment.
Please update the PR body to use the "I am adding a new extension to a language." part of the template and fill it in as if you're adding an extension.
The important part is we need real-world samples with their original filenames, and a link to the original source location and the license for legal reasons.
Please also add equivalent samples for TypeScript too.
|
@lildude Hold on, I thought Linguist had troubles disambiguating between multiple languages that share the same interpreter? (Or am I misremembering something?) I ask because |
This file demonstrates OOP in Deno using TypeScript with a User class that encapsulates user data and provides methods to display and update user information.
This script demonstrates OOP principles in TypeScript using Bun, including abstraction, encapsulation, inheritance, and polymorphism.
Added a software license notice to the deno.ts file.
Added author, copyright, and license information to the file.
Added author, copyright, and license comments to deno.js
I thought the same thing but this PR prompted me to look at the code again and I found it works like all the other strategies (makes sense) and the shebang strategy will return multiple languages down to the next strategy. The only issue seems to have been that the tests didn't expect this, but they do now thanks to the changes in this PR. |
Added the bun and deno interpreters to languages.yml.
Description
This PR adds 4 examples, each with the MIT license, and adds the deno and bun interpreters to languages.yml for the
JavaScriptlanguage. The license(s) are included as comments in the code.Checklist: