| 52 | }; |
| 53 | |
| 54 | function runCommand(command, args) { |
| 55 | return new Promise((resolve, reject) => { |
| 56 | const child = spawn(command, args); |
| 57 | |
| 58 | child.stdout.on('data', (data) => { |
| 59 | console.log(`${data}`); |
| 60 | }); |
| 61 | |
| 62 | child.stderr.on('data', (data) => { |
| 63 | console.error(`${data}`); |
| 64 | }); |
| 65 | |
| 66 | child.on('close', (code) => { |
| 67 | if (code !== 0) { |
| 68 | reject(new Error(`${command} ${args.join(' ')} 进程退出,退出码 ${code}`)); |
| 69 | } else { |
| 70 | resolve(); |
| 71 | } |
| 72 | }); |
| 73 | }); |
| 74 | } |
| 75 | |
| 76 | export const isDarwin = () => os.platform() === 'darwin'; |
| 77 | |