const { exec } = require('child_process'); const executeCommand = (command) => { return new Promise((resolve, reject) => { exec(command, (error, stdout, stderr) => { if (error) { reject(`Error: ${error.message}`); return; } if (stderr) { console.log(`stderr: ${stderr}`); } console.log(`stdout: ${stdout}`); resolve(); }); }); }; (async () => { try { await executeCommand('hexo cl'); await executeCommand('hexo g'); await executeCommand('pnpm run search'); await executeCommand('git add .'); await executeCommand(`git commit -m 'update'`); await executeCommand(`git push`); } catch (error) { console.error(`Execution failed: ${error}`); } })();