Skip to content

Commit

Permalink
Feat: change runSync to get
Browse files Browse the repository at this point in the history
  • Loading branch information
pandaoh committed Apr 12, 2024
1 parent 7e1ea61 commit 6c736f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions bin/xcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,24 @@ program
.action(() => {
let cmdStr = 'npm i nrm pnpm cnpm js-xcmd nodemon pm2 yarn rimraf protobufjs protobufjs-cli -g';
console.log({ cmdStr });
const result = nodeCmd.runSync(cmdStr);
console.log(result.stderr);
if (result.err) return console.log(`%c出错啦!${result.data}`, 'color:red;');
console.log(result.data);
console.log('----------Successful----------');

const cmdProcess = nodeCmd.get(cmdStr);

cmdProcess.stdout.on('data', (data) => {
console.log(data);
});

cmdProcess.stderr.on('data', (data) => {
console.error(data);
});

cmdProcess.on('close', (code) => {
if (code === 0) {
console.log('----------Successful----------');
} else {
console.log(`%c出错啦!退出码: ${code}`, 'color:red;');
}
});
});

program
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-xcmd",
"version": "1.4.11",
"version": "1.4.12",
"description": "XCmd library for node.js.",
"main": "main.js",
"bin": {
Expand Down

0 comments on commit 6c736f2

Please sign in to comment.