-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcommit.js
46 lines (43 loc) · 1.31 KB
/
commit.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
const { exec, spawn } = require("child_process");
const jExec = async (command) => {
const spawnCommand = command.split(" ")[0];
const spawnArgs = command.split(" ").slice(1);
await new Promise((resolve) => {
let std = spawn(spawnCommand, spawnArgs || [], {
shell: true,
stdio: "inherit",
});
std.on("data", (data) => {
console.log(`stdout: ${data}`);
});
std.on("error", (error) => {
console.log(`error: ${error.message}`);
});
std.on("close", () => {
resolve();
});
});
};
(async () => {
try {
exec("pwd");
} catch (e) {
console.log("Please use Git Bash to run this script");
process.exit();
}
const message = process.argv[2];
if (!message) {
console.log("Please enter a commit message");
} else {
console.log("\npnpm build");
await jExec(`pnpm build`);
console.log("\nCommitting Static HTML...");
await jExec(
`cd out && git init && git remote add static-html https://github.com/joonshakya/CSIT21-Next-Static.git && git add . && git branch -M static && git commit -m "Deploy from local" && git config http.postBuffer 524288000 && git push static-html static --force`
);
console.log("\nCommitting code...");
await jExec(
`git add . && git commit -m "${message} [skip ci]" && git push`
);
}
})();