blog-hexo/ci.js
2023-11-17 12:58:51 +08:00

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}`);
}
})();