forked from it-ebooks/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.js
39 lines (35 loc) · 822 Bytes
/
update.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
var process = require('child_process');
var getTimeStr = function() {
var tm = new Date();
var o = {
yr: tm.getFullYear(),
mon: tm.getMonth() + 1,
dt: tm.getDate(),
hr: tm.getHours(),
min: tm.getMinutes(),
sec: tm.getSeconds()
};
for(var i in o)
{
o[i] = o[i].toString();
if(o[i].length < 2)
o[i] = '0' + o[i];
}
return o.yr + '-' + o.mon + '-' + o.dt +
' ' + o.hr + ':' + o.min + ':' + o.sec;
};
var cmds = [
'git add -A',
'git commit -m "' + getTimeStr() + '"',
'git push',
'hexo clean',
'hexo g -d'
];
for(var cmd of cmds) {
try {
console.log(cmd);
console.log(process.execSync(cmd).toString());
} catch(ex) {
console.log(ex.toString());
}
}