Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Support #44

Closed
wants to merge 15 commits into from
Closed
5 changes: 3 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ Display question details. With `-g`/`-l`/`-x`, the code template would be auto g
* golang
* java
* javascript
* kotlin
* mysql
* php
* python
Expand Down Expand Up @@ -467,7 +468,7 @@ Display version information.
Short:

$ leetcode version
2.6.1
2.6.2

Verbose:

Expand All @@ -477,7 +478,7 @@ Verbose:
| | ___ ___| |_ ___ ___ __| | ___
| |/ _ \/ _ \ __|/ __|/ _ \ / _` |/ _ \
| | __/ __/ |_ (__| (_) | (_| | __/
|_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.1
|_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.2

[Environment]
Node v8.1.4
Expand Down
4 changes: 4 additions & 0 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
layout: default
title: Release Notes
---
# 2.6.2
* `submit`
* fixes beta ratio issue

# 2.6.1
* `submit`
* fixes 500 error on windows.
Expand Down
1 change: 1 addition & 0 deletions lib/commands/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ cmd.handler = function(argv) {
// printLine(result, 'Your runtime beats %d %% of %s submissions',
// ratio.toFixed(2), lang);
// });

} else {
result.testcase = result.testcase.slice(1, -1).replace(/\\n/g, '\n');
printResult(result, 'error');
Expand Down
3 changes: 2 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const DEFAULT_CONFIG = {
'ruby',
'rust',
'scala',
'swift'
'swift',
'typescript'
],
urls: {
// base urls
Expand Down
3 changes: 2 additions & 1 deletion lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const LANGS = [
{lang: 'ruby', ext: '.rb', style: '#'},
{lang: 'rust', ext: '.rs', style: 'c'},
{lang: 'scala', ext: '.scala', style: 'c'},
{lang: 'swift', ext: '.swift', style: 'c'}
{lang: 'swift', ext: '.swift', style: 'c'},
{lang: 'typescript', ext: '.ts', style: 'c'}
];

const h = {};
Expand Down
8 changes: 5 additions & 3 deletions test/test_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('helper', function() {
assert.equal(h.langToExt('rust'), '.rs');
assert.equal(h.langToExt('scala'), '.scala');
assert.equal(h.langToExt('swift'), '.swift');
assert.equal(h.langToExt('rust'), '.rs');
assert.equal(h.langToExt('typescript'), '.ts');
});
}); // #langToExt

Expand All @@ -150,14 +150,15 @@ describe('helper', function() {
assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql');
assert.equal(h.extToLang('~/leetcode/hello.php'), 'php');
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');
// typescript also allowed
assert.equal(h.extToLang('/home/skygragon/file.dat'), 'unknown');
assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust');
});
}); // #extToLang

Expand All @@ -180,6 +181,7 @@ describe('helper', function() {
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