-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
55 lines (53 loc) · 1.16 KB
/
deploy.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
#!/usr/bin/env node
const spawn = require('cross-spawn');
const inquirer = require('inquirer');
const path = require('path');
inquirer
.prompt([
{
type: 'rawlist',
message: '选择操作',
name: 'operate',
choices: [
{
name: '启动服务',
value: 'server',
},
{
name: '编译打包',
value: 'build',
},
{
name: '仅发布',
value: 'publish',
},
{
name: '打包部署',
value: 'buildPublish',
}
]
},
])
.then((answer) => {
switch (answer.operate) {
case 'server':
spawn.sync('npm', ['run', 'server'], {cwd: __dirname, stdio: 'inherit'});
break;
case 'build':
spawn('npm', ['run', 'build']);
break;
case 'publish':
upload();
break;
case 'buildPublish':
spawn.sync('npm', ['run', 'build']);
upload();
break;
default:
console.log('请选择操作');
break;
}
});
function upload() {
spawn.sync('rsync', ['-avzP', 'public/', '[email protected]::blog'], {stdio: 'inherit'});
}