CoolFace
Apppublic

justest/ai-support

sourceHugging Faceupdated 3y agoView on Hugging Face
1likes
auto-commit.js36 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  console.log(new Date(), 'auto commit start')20  const dirs = fs.readdirSync(root)21  for (let dir of dirs) {22    const cwd = path.join(root, dir)23    if (fs.existsSync(path.join(cwd, '.git/config'))) {24      console.log('auto commit', cwd)25      exec(`git add -A`, { cwd })26      exec(`git commit -am "[WIP] auto commit"`, { cwd })27      exec(`git push`, { cwd })28      console.log('done')29    }30  }31}32// loop()33const timeout = process.env.AUTO_COMMIT || 8640034if (timeout > 600) {35  setInterval(loop, 1000 * timeout)36}