Skip to content

Commit

Permalink
Add CommonJS file glob to JavaScript lexer (#1511)
Browse files Browse the repository at this point in the history
This commit adds the `*.cljs` fille glob to the JavaScript lexer.
Node.js treats files ending in the `.cjs` extension as CommonJS modules.

Co-authored-by: Michael Camilleri <mike@inqk.net>
  • Loading branch information
AndrewKvalheim and pyrmont committed May 12, 2020
1 parent ead03fa commit 8e26a63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/javascript.rb
Expand Up @@ -15,7 +15,7 @@ class Javascript < RegexLexer

tag 'javascript'
aliases 'js'
filenames '*.js', '*.mjs'
filenames '*.cjs', '*.js', '*.mjs'
mimetypes 'application/javascript', 'application/x-javascript',
'text/javascript', 'text/x-javascript'

Expand Down
2 changes: 2 additions & 0 deletions spec/lexers/javascript_spec.rb
Expand Up @@ -17,7 +17,9 @@
include Support::Guessing

it 'guesses by filename' do
assert_guess :filename => 'foo.cjs'
assert_guess :filename => 'foo.js'
assert_guess :filename => 'foo.mjs'
end

it 'guesses by mimetype' do
Expand Down

0 comments on commit 8e26a63

Please sign in to comment.