Team Ai
Apppublic

justest/leetcode

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
auto-commit.js33 linesDownload Raw Back to root
1const fs = require('fs')2const path = require('path')3const execSync = require('child_process').execSync4 5function 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 17const root = __dirname18function loop() {19  const dirs = fs.readdirSync(root)20  for (let dir of dirs) {21    const cwd = path.join(root, dir)22    if (fs.existsSync(path.join(cwd, '.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 })27      console.log('done')28    }29  }30}31// loop()32setInterval(loop, 600 * 1000)33