Create auto-commit.js
Browse files- auto-commit.js +17 -0
auto-commit.js
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const fs = require('fs')
|
2 |
+
const path = require('path')
|
3 |
+
const exec = require('child_process').execSync
|
4 |
+
|
5 |
+
function loop() {
|
6 |
+
const dirs = fs.readdirSync('/home/user/app')
|
7 |
+
for (let dir of dirs) {
|
8 |
+
if (fs.existsSync(path.join(dir, '.git/config'))) {
|
9 |
+
console.log('auto commit', dir)
|
10 |
+
exec(`git add -A`)
|
11 |
+
exec(`git commit -am "[WIP] auto commit"`)
|
12 |
+
exec(`git push`)
|
13 |
+
console.log('done')
|
14 |
+
}
|
15 |
+
}
|
16 |
+
}
|
17 |
+
setInterval(loop, 600)
|