blog-hexo/ci.js

46 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2023-11-17 13:12:11 +08:00
const { exec } = require('child_process')
2023-11-17 12:58:51 +08:00
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}`);
}
})();
2023-11-17 13:12:11 +08:00
// const execa = require('execa');
// (async () => {
// try {
// await execa('hexo', ['cl']);
// await execa('hexo', ['g']);
// await execa('pnpm', ['run', 'search']);
// await execa('git', ['add', '.']);
// console.log('All commands executed successfully.');
// } catch (error) {
// console.error(`Execution failed: ${error.message}`);
// }
// })();