Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Add CommonJS file glob to JavaScript lexer (rouge-ruby#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
2 people authored and mattt committed May 21, 2020
1 parent 1dc81df commit aa55875
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 aa55875

Please sign in to comment.