46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
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}`);
|
|
}
|
|
})();
|
|
|
|
|
|
|
|
// 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}`);
|
|
// }
|
|
// })();
|