-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgit.js
50 lines (43 loc) · 991 Bytes
/
git.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const { exec } = require("child_process");
require('dotenv').config();
const commitCount = process.env.COMMIT_COUNT;
const pushThreshold = process.env.PUSH_THRESHOLD;
const gitPull = () => {
return exec("git pull", (err, stdout, stderr) => {
if (err) {
console.log("🔥 pull error: ", err);
return;
}
console.log(`🚀 : ${stdout}`);
});
};
const gitCommit = () => {
return exec(
'git commit --allow-empty -m "go + git + github = 💥"',
(err, stdout, stderr) => {
if (err) {
return;
}
console.log(`🚀 : ${stdout}`);
}
);
};
const gitPush = () => {
return exec("git push", (err, stdout, stderr) => {
if (err) {
console.log("🔥 push error: ", err);
return;
}
console.log(`🛬 pushed successfully: ${stdout}`);
});
};
const run = () => {
gitPull();
for (let i = 0; i < commitCount; i++) {
gitCommit();
if (i % pushThreshold === 0) {
gitPush();
}
}
};
run();