forked from linhay/hexo_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.js
More file actions
32 lines (28 loc) · 758 Bytes
/
task.js
File metadata and controls
32 lines (28 loc) · 758 Bytes
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
const shell = require('shelljs')
function updateHexo() {
shell.cd('/hexo/')
// shell.exec('git checkout .')
var stdout = shell.exec('git pull').stdout
if (stdout == 'Already up-to-date.\n') { return false }
console.log(stdout)
return true
}
function updatePost() {
shell.cd('/hexo/source/')
// shell.exec('git checkout .')
var stdout = shell.exec('git pull').stdout
if (stdout == 'Already up-to-date.\n') { return false }
console.log(stdout)
return true
}
function update() {
if (updatePost() || updateHexo()) {
shell.cd('/hexo/')
shell.exec('/usr/local/bin/hexo clean')
shell.exec('/usr/local/bin/hexo d -g')
}
}
setInterval(() => {
update()
shell.exit(0)
}, 5000)