File size: 777 Bytes
0564162
 
546f906
 
 
 
 
 
 
 
 
 
 
 
 
0564162
3a03dc0
0564162
3a03dc0
0564162
3a03dc0
0d37e54
546f906
3a03dc0
 
 
0564162
 
 
 
546f906
5d78de2
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
const fs = require('fs')
const path = require('path')
const execSync = require('child_process').execSync

function exec(command, options) {
  try {
    const { stdout, stderr } = execSync(command, options)
    if (stderr) {
      throw new Error(stderr)
    }
    console.log(stdout)
  } catch (e) {
    console.log('Exec Error:', e)
  }
}

const root = __dirname
function loop() {
  const dirs = fs.readdirSync(root)
  for (let dir of dirs) {
    const cwd = path.join(root, dir)
    if (fs.existsSync(path.join(cwd, '.git/config'))) {
      console.log('auto commit', cwd)
      exec(`git add -A`, { cwd })
      exec(`git commit -am "[WIP] auto commit"`, { cwd })
      exec(`git push`, { cwd })
      console.log('done')
    }
  }
}
// loop()
setInterval(loop, 600 * 1000)