forked from sealtalk/sealtalk-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.js
68 lines (59 loc) · 1.99 KB
/
install.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 exec = require('child_process').exec;
var os = require('os');
var showResult = function(err, stdout) {
console.log(err || stdout);
};
var execShell = function(shell, callback) {
exec(shell, function(err, stdout, stderr) {
callback(err, stdout);
});
};
var addSudo = function() {
return os.platform() == 'linux' ? 'sudo ' : '';
};
var getMethod = function() {
return os.platform() == 'linux' ? 'export' : 'set';
};
var initGrunt = function() {
var shell = addSudo() + 'npm install -g grunt-cli';
execShell(shell, function(err, stdout) {
showResult(err, stdout);
next();
});
};
var initDeps = function() {
var shell = addSudo() + 'npm install';
execShell(shell, function(err, stdout) {
showResult(err, stdout);
next();
});
};
var initDB = function() {
var shell = 'node sync.js --harmony';
execShell(shell, function(err, stdout) {
showResult(err, stdout);
var logs = ['',
'初始化已完成,请在下方命令行执行: ',
'-----------------------------------------------',
'1、设置环境变量: |',
' |',
' Windows : set NODE_ENV=development |',
' |',
' Mac/Linux: export NODE_ENV=development |',
'-----------------------------------------------',
'2、启动服务: |',
' |',
' grunt nodemon |',
'-----------------------------------------------'];
!err && showResult(logs.join('\n'));
});
};
var methods = [initGrunt, initDeps, initDB],
index = 0;
var next = function() {
showResult('正在初始化,请耐心等待...');
methods[index]();
index++;
};
next();
// initDB();