From 54e81dd8fb2f433147de57dc34847658414caca0 Mon Sep 17 00:00:00 2001 From: Aseem Kishore Date: Mon, 2 Apr 2012 19:56:28 -0400 Subject: [PATCH 1/2] Add ._js & ._coffee extensions for Streamline.js. Streamline.js by Bruno Jouhier (@Sage) is a library/tool that lets you write synchronous-looking JavaScript/CoffeeScript, and have it compile to Node-style asynchronous JavasScript/CoffeeScript. (It's amazing and super elegant.) https://github.com/Sage/streamlinejs From the start, Streamline was designed to be exactly JavaScript/CoffeeScript, so that it works with existing editors and tools. No new keywords or syntax -- it simply reserves `_` as a function parameter name. Streamline files have thus kept `.js` and `.coffee` as extensions, so that no changes need to be made to tools; Streamline has just used the convention of ending file basenames with `_`, like `foo_.js` or `foo_.coffee`. Unfortunately, to get the most optimal Node.js integration, with on-the-fly compilation (like CoffeeScript), files now need to have their own extension. So Bruno has decided to make `._js` and `._coffee` the extensions of choice. The good news is that the language is still exactly JavaScript/CoffeeScript; it's only the extension that's changed. It's simple to add these extensions into our editors, but I'm wondering if we can add this to GitHub too. =) This change is super simple and shouldn't affect any other language, so I hope you guys are open to it. Thanks for your consideration! --- lib/linguist/languages.yml | 2 ++ test/test_language.rb | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index a470f579..61e790ba 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -217,6 +217,7 @@ CoffeeScript: aliases: - coffee extensions: + - ._coffee - .coffee filenames: - Cakefile @@ -586,6 +587,7 @@ JavaScript: - node primary_extension: .js extensions: + - ._js - .bones - .jake - .js diff --git a/test/test_language.rb b/test/test_language.rb index 5186af52..90a5e26a 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -252,6 +252,11 @@ class TestLanguage < Test::Unit::TestCase assert_equal Language['PHP'], Language.find_by_extension('php5') assert_equal Language['PowerShell'], Language.find_by_extension('psm1') assert_equal Language['PowerShell'], Language.find_by_extension('ps1') + + # Aliases for Streamline.js ( https://github.com/Sage/streamlinejs ) + assert_equal Language['JavaScript'], Language.find_by_extension('_js') + assert_equal Language['CoffeeScript'], Language.find_by_extension('_coffee') + assert_nil Language.find_by_extension('.nkt') end From 17adccc844b2996f75b492a0b4053d90d3df3bee Mon Sep 17 00:00:00 2001 From: Aseem Kishore Date: Tue, 3 Apr 2012 14:55:34 -0400 Subject: [PATCH 2/2] Regression fix: ensure .coffee is primary ext. (The primary extension by default is the first extension, but the extensions need to be in alphabetical order, and _coffee comes before coffee.) --- lib/linguist/languages.yml | 2 +- test/test_language.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 61e790ba..91224b22 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -216,9 +216,9 @@ CoffeeScript: ace_mode: coffee aliases: - coffee + primary_extension: .coffee extensions: - ._coffee - - .coffee filenames: - Cakefile diff --git a/test/test_language.rb b/test/test_language.rb index 90a5e26a..a214adc3 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -337,6 +337,8 @@ class TestLanguage < Test::Unit::TestCase assert_equal '.pl', Language['Perl'].primary_extension assert_equal '.py', Language['Python'].primary_extension assert_equal '.rb', Language['Ruby'].primary_extension + assert_equal '.js', Language['JavaScript'].primary_extension + assert_equal '.coffee', Language['CoffeeScript'].primary_extension # This is a nasty requirement, but theres some code in GitHub that # expects this. Really want to drop this.