8000 [Plugin] support config for plugins. · liaoziyang/leetcode-cli@aa4606a · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aa4606a

Browse files
committed
[Plugin] support config for plugins.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent af1b147 commit aa4606a

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ var DEFAULT_SYS_CONFIG = {
3636
'algorithms',
3737
'database',
3838
'shell'
39-
]
39+
],
40+
41+
PLUGINS: {}
4042
};
4143

4244
// but you will want change these

lib/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var h = require('./helper');
99
var Plugin = require('./plugin');
1010
var session = require('./session');
1111

12-
var core = new Plugin('core', 'Core', '20170722', 'Plugins manager');
12+
var core = new Plugin(99999999, 'core', '20170722', 'Plugins manager');
1313

1414
core.getProblem = function(keyword, cb) {
1515
this.getProblems(function(e, problems) {

lib/plugin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
var _ = require('underscore');
22

33
var h = require('./helper');
4+
var config = require('./config');
45
var log = require('./log');
56

67
function Plugin(id, name, ver, desc) {
78
this.id = id;
89
this.name = name;
910
this.ver = ver || 'default';
1011
this.desc = desc;
11-
this.next = null;
1212
}
1313

1414
Plugin.prototype.init = function() {
15+
this.config = config.PLUGINS[this.name] || {};
16+
this.next = null;
1517
};
1618

1719
Plugin.prototype.setNext = function(next) {

lib/plugins/cache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var session = require('../session');
99
var plugin = new Plugin(20, 'cache', '', 'Plugin to provide local cache.');
1010

1111
plugin.init = function() {
12+
Plugin.prototype.init.call(this);
1213
cache.init();
1314
};
1415

0 commit comments

Comments
 (0)
0