-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_git_command_date.js
More file actions
39 lines (31 loc) · 965 Bytes
/
run_git_command_date.js
File metadata and controls
39 lines (31 loc) · 965 Bytes
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
const child_process = require('child_process');
const util = require('util');
const exec = util.promisify(child_process.exec);
let fs = require('fs')
var day = new Date().toUTCString();
console.log("Running on " + day);
var cmd = `git add *
git commit -m "Check the update on ${day}."`;
var cmds = cmd.split("\n");
fs.writeFileSync("./updatetime.txt", day);
const runClean = async function () {
// cwd指定子进程的当前工作目录 这里的rm -rf build为删除指定目录下的一个文件夹
try {
for (var i = 0; i < cmds.length; i++) {
await exec(cmds[i], { cwd: "." });
}
} catch (e) {
console.warn("STDERR #" + (i + 1) + ": " + e.message);
}
}
runClean().then(() => {
console.log("Done CMD #1")
}).then(() => {
console.log("Done CMD #2")
}).then(() => {
console.log("Done CMD #3")
}).then(() => {
console.log("Done CMD #4")
}).then(() => {
console.log("Done CMD #5")
});