Download auto-commit.js from justest/leetcode: direct link, hf CLI and curl.
- Browser
- Download file 777 Bytes
-
https://huggingface.co/spaces/justest/leetcode/resolve/main/auto-commit.js
- Command line
-
hf download hf://spaces/justest/leetcode/auto-commit.js
-
curl -L -o auto-commit.js https://huggingface.co/spaces/justest/leetcode/resolve/main/auto-commit.js
777 Bytes
| 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) | |