-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proportional.js
46 lines (44 loc) · 917 Bytes
/
proportional.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
const ContextManager = require('./context-manager');
class Proportional {
constructor() {
const methods = [
'levels',
'defaultLevel',
'usage',
'threshold',
'options',
'version',
'alias',
'help',
'upgrade',
'downgrade',
'hook',
];
this.store = [];
methods.forEach((m, i) => {
this[m] = function(args) {
this.store[i] = [m, args];
};
});
}
run(args) {
const ctx = new ContextManager();
this.store.forEach((m) => {
if (ctx[m[0]]) {
ctx[m[0]](m[1]);
}
});
ctx._writeRC();
ctx._ContextShouldUpdate();
ctx._processArgs(args);
if (ctx._cli.hook) {
return ctx._cli.hook(process.argv);
}
ctx._outputArgs = ctx._parseArgs(ctx._CLIArgs);
return {
argv: ctx._CLIArgs,
output: ctx._outputArgs,
};
}
}
module.exports = Proportional;