Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ Display question details. With `-g`/`-l`/`-x`, the code template would be auto g
* javascript
* kotlin
* mysql
* php
* python
* python3
* ruby
Expand Down
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const DEFAULT_CONFIG = {
'javascript',
'kotlin',
'mysql',
'php',
'python',
'python3',
'ruby',
Expand Down
1 change: 1 addition & 0 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const LANGS = [
{lang: 'javascript', ext: '.js', style: 'c'},
{lang: 'kotlin', ext: '.kt', style: 'c'},
{lang: 'mysql', ext: '.sql', style: '--'},
{lang: 'php', ext: '.php', style: 'c'},
{lang: 'python', ext: '.py', style: '#'},
{lang: 'python3', ext: '.py', style: '#'},
{lang: 'ruby', ext: '.rb', style: '#'},
Expand Down
10 changes: 7 additions & 3 deletions test/test_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ describe('helper', function() {
assert.equal(h.langToExt('java'), '.java');
assert.equal(h.langToExt('javascript'), '.js');
assert.equal(h.langToExt('mysql'), '.sql');
assert.equal(h.langToExt('php'), '.php');
assert.equal(h.langToExt('python'), '.py');
assert.equal(h.langToExt('python3'), '.py');
assert.equal(h.langToExt('ruby'), '.rb');
assert.equal(h.langToExt('rust'), '.rs');
assert.equal(h.langToExt('scala'), '.scala');
assert.equal(h.langToExt('swift'), '.swift');
assert.equal(h.langToExt('rust'), '.rs');
});
}); // #langToExt

Expand All @@ -146,13 +147,14 @@ describe('helper', function() {
assert.equal(h.extToLang('../file.go'), 'golang');
assert.equal(h.extToLang('file.java'), 'java');
assert.equal(h.extToLang('c:/file.js'), 'javascript');
assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql');
assert.equal(h.extToLang('~/leetcode/hello.php'), 'php');
assert.equal(h.extToLang('c:/Users/skygragon/file.py'), 'python');
assert.equal(h.extToLang('~/file.rb'), 'ruby');
assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust');
assert.equal(h.extToLang('/tmp/file.scala'), 'scala');
assert.equal(h.extToLang('~/leetcode/file.swift'), 'swift');
assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql');
assert.equal(h.extToLang('/home/skygragon/file.dat'), 'unknown');
assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust');
});
}); // #extToLang

Expand All @@ -170,9 +172,11 @@ describe('helper', function() {
assert.deepEqual(h.langToCommentStyle('java'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('javascript'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('mysql'), SQL_STYLE);
assert.deepEqual(h.langToCommentStyle('php'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('python'), RUBY_STYLE);
assert.deepEqual(h.langToCommentStyle('python3'), RUBY_STYLE);
assert.deepEqual(h.langToCommentStyle('ruby'), RUBY_STYLE);
assert.deepEqual(h.langToCommentStyle('rust'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('scala'), C_STYLE);
assert.deepEqual(h.langToCommentStyle('swift'), C_STYLE);
});
Expand Down