diff --git a/AutoCommitPush.mjs b/AutoCommitPush.mjs index 5c14023..86340f8 100644 --- a/AutoCommitPush.mjs +++ b/AutoCommitPush.mjs @@ -1,5 +1,19 @@ import shell from "shelljs"; import _readline from "readline"; +import { exec } from 'node:child_process'; +import { resolve } from "path"; + +const execSync = (command)=>new Promise((resolve,rejects)=>{ + exec(command,(err,stdout,stderr)=>{ + if(err){ + console.error(stderr) + rejects(stderr) + }else{ + console.log(stdout) + resolve(stdout) + } + }) +}) const readline = _readline.createInterface({ input: process.stdin, @@ -37,7 +51,7 @@ const generateDate = function () { ;(async function(){ const remark = await input('remark:') const message = `update:${generateDate()} ${remark ? '-remark:'+remark : ''} -AutoCommit` - shell.exec(`git add ."`); - shell.exec(`git commit -m "${message}"`); - shell.exec("git push"); + await execSync(`git add ."`); + await execSync(`git commit -m "${message}"`); + await execSync("git push"); })()