forked from skygragon/leetcode-cli
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathconfig.js
68 lines (59 loc) · 1.8 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
var _ = require('underscore');
var h = require('./helper');
// usually you don't wanna change those
var DEFAULT_SYS_CONFIG = {
URL_BASE: 'https://leetcode.com',
URL_LOGIN: 'https://leetcode.com/accounts/login/',
URL_PROBLEMS: 'https://leetcode.com/api/problems/$category/',
URL_PROBLEM: 'https://leetcode.com/problems/$slug',
URL_TEST: 'https://leetcode.com/problems/$slug/interpret_solution/',
URL_SUBMIT: 'https://leetcode.com/problems/$slug/submit/',
URL_SUBMISSIONS: 'https://leetcode.com/api/submissions/$slug',
URL_SUBMISSION: 'https://leetcode.com/submissions/detail/$id/',
URL_VERIFY: 'https://leetcode.com/submissions/detail/$id/check/',
URL_FAVORITES: 'https://leetcode.com/list/api/questions',
URL_FAVORITE_DELETE: 'https://leetcode.com/list/api/questions/$hash/$id',
LANGS: [
'bash',
'c',
'cpp',
'csharp',
'golang',
'java',
'javascript',
'mysql',
'python',
'python3',
'ruby',
'scala',
'swift'
]
};
// but you will want change these
var DEFAULT_USER_CONFIG = {
AUTO_LOGIN: false,
COLOR_THEME: 'default',
ICON_THEME: '',
LANG: 'cpp',
MAX_WORKERS: 10,
USE_COLOR: true
};
function Config() {}
Config.prototype.init = function() {
// check local config: ~/.lcconfig
var localConfig = JSON.parse(h.getFileData(h.getConfigFile())) || {};
_.extendOwn(this, this.getDefaultConfig());
_.extendOwn(this, localConfig);
};
Config.prototype.getDefaultConfig = function() {
var cfg = {};
_.extendOwn(cfg, DEFAULT_SYS_CONFIG);
_.extendOwn(cfg, DEFAULT_USER_CONFIG);
return cfg;
};
Config.prototype.getUserConfig = function() {
return _.pick(this, function(v, k) {
return k in DEFAULT_USER_CONFIG;
});
};
module.exports = new Config();