Update auto-commit.js
Browse files- auto-commit.js +15 -2
auto-commit.js
CHANGED
@@ -1,6 +1,18 @@
|
|
1 |
const fs = require('fs')
|
2 |
const path = require('path')
|
3 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
const root = __dirname
|
6 |
function loop() {
|
@@ -8,7 +20,7 @@ function loop() {
|
|
8 |
for (let dir of dirs) {
|
9 |
const cwd = path.join(root, dir)
|
10 |
if (fs.existsSync(path.join(dir, '.git/config'))) {
|
11 |
-
console.log('auto commit',
|
12 |
exec(`git add -A`, { cwd })
|
13 |
exec(`git commit -am "[WIP] auto commit"`, { cwd })
|
14 |
exec(`git push`, { cwd })
|
@@ -16,4 +28,5 @@ function loop() {
|
|
16 |
}
|
17 |
}
|
18 |
}
|
|
|
19 |
setInterval(loop, 600 * 1000)
|
|
|
1 |
const fs = require('fs')
|
2 |
const path = require('path')
|
3 |
+
const execSync = require('child_process').execSync
|
4 |
+
|
5 |
+
function exec(command, options) {
|
6 |
+
try {
|
7 |
+
const { stdout, stderr } = execSync(command, options)
|
8 |
+
if (stderr) {
|
9 |
+
throw new Error(stderr)
|
10 |
+
}
|
11 |
+
console.log(stdout)
|
12 |
+
} catch (e) {
|
13 |
+
console.log('Exec Error:', e)
|
14 |
+
}
|
15 |
+
}
|
16 |
|
17 |
const root = __dirname
|
18 |
function loop() {
|
|
|
20 |
for (let dir of dirs) {
|
21 |
const cwd = path.join(root, dir)
|
22 |
if (fs.existsSync(path.join(dir, '.git/config'))) {
|
23 |
+
console.log('auto commit', cwd)
|
24 |
exec(`git add -A`, { cwd })
|
25 |
exec(`git commit -am "[WIP] auto commit"`, { cwd })
|
26 |
exec(`git push`, { cwd })
|
|
|
28 |
}
|
29 |
}
|
30 |
}
|
31 |
+
// loop()
|
32 |
setInterval(loop, 600 * 1000)
|