update:2024-08-07 11:10:15 -remark:update update.mjs,now we can use 'pnpm run push' to push the code\ -AutoCommit

This commit is contained in:
539943419 committed 2024-07-06 10:09:14 +08:00
1 parent 222b0ac434
commit cbecc3a240
2 files changed
+48 -16

No files matched your search

+4 -1
View File
@@ -1,5 +1,8 @@
{ {
"dependencies": { "dependencies": {
"shelljs": "^0.8.5" "shelljs": "^0.8.5"
},
"scripts": {
"push": "node update.mjs"
} }
} }
+44 -15
View File
@@ -1,15 +1,44 @@
import shell from 'shelljs' import shell from "shelljs";
const generateDate = function(){ import _readline from "readline";
const dateNow = new Date() import { rejects } from "assert";
let year = dateNow.getFullYear();
let month = ("0" + (dateNow.getMonth() + 1)).slice(-2); const readline = _readline.createInterface({
let day = ("0" + dateNow.getDate()).slice(-2); input: process.stdin,
let hour = dateNow.getHours(); output: process.stdout
let minute = dateNow.getMinutes(); });
let seconds = dateNow.getSeconds();
return `${year}-${month}-${day} ${hour}:${minute}:${seconds}` const input = async function (question) {
} return await new Promise((resolve, rejects) => {
// console.log(generateDate()) try {
shell.exec('git add .') readline.question(question, output => {
shell.exec(`git commit -m "update:${generateDate()} AutoCommit"`) readline.close();
shell.exec('git push') resolve(output);
});
} catch (e) {
rejects(e);
}
});
};
const generateDate = function () {
const dateNow = new Date();
const paddingNumber = function(num){
return ("0" + (num + 1)).slice(-2)
}
let year = dateNow.getFullYear();
let month = paddingNumber((dateNow.getMonth() + 1));
let day = paddingNumber(dateNow.getDate());
let hour = paddingNumber(dateNow.getHours());
let minute = paddingNumber(dateNow.getMinutes());
let seconds = paddingNumber(dateNow.getSeconds());
return `${year}-${month}-${day} ${hour}:${minute}:${seconds}`;
};
;(async function(){
const remark = await input('remark:')
const message = `update:${generateDate()} ${remark ? '-remark:'+remark : ''} -AutoCommit`
// console.log(message)
shell.exec(`git commit -am "${message}"`);
shell.exec("git push");
})()