-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (38 loc) · 1.13 KB
/
index.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
#!/usr/bin/env node
"use strict";
if(!process.env.NODE_ENV){
process.env.NODE_ENV = 'production';
}
process.umask(0o022); // Some system default permission is 700.
const { username } = require('./lib/constant.js');
const { errLog } = require('./lib/util/util.js');
const os = require('os');
function manage(command, cliVersion){
if(command === '-v'){ // everybody
require('./lib/version')(cliVersion);
return;
}
const userInfo = os.userInfo();
if(userInfo.username !== username){
errLog(`You are not user '${username}'.`);
return;
}
if(command === 'install'){
require('./lib/install')(cliVersion);
} else if(command === 'update'){
require('./lib/update')(cliVersion);
} else if(command === 'reload'){
require('./lib/reload')();
} else if(command === 'start'){
require('./lib/start')();
} else if(command === 'stop'){
require('./lib/stop')();
} else if(command === 'serverinfo'){
require('./lib/server-info')();
} else if(command === 'restart'){
require('./lib/restart')();
} else {
errLog(`Unsupported command: '${command}'`);
}
}
module.exports = manage;