| const fs = require('fs') | |
| const path = require('path') | |
| const exec = require('child_process').execSync | |
| 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(dir, '.git/config'))) { | |
| console.log('auto commit', dir) | |
| exec(`git add -A`, { cwd }) | |
| exec(`git commit -am "[WIP] auto commit"`, { cwd }) | |
| exec(`git push`, { cwd }) | |
| console.log('done') | |
| } | |
| } | |
| } | |
| setInterval(loop, 600 * 1000) | |