31 lines
753 B
JavaScript
31 lines
753 B
JavaScript
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}`);
|
|
}
|
|
})();
|