(process: string, workingDirectory?: string, channel?: vscode.OutputChannel)
| 722 | } |
| 723 | |
| 724 | export function execChildProcess(process: string, workingDirectory?: string, channel?: vscode.OutputChannel): Promise<string> { |
| 725 | return new Promise<string>((resolve, reject) => { |
| 726 | child_process.exec(process, { cwd: workingDirectory, maxBuffer: 500 * 1024 }, (error: Error | null, stdout: string, stderr: string) => { |
| 727 | if (channel) { |
| 728 | let message: string = ""; |
| 729 | let err: boolean = false; |
| 730 | if (stdout && stdout.length > 0) { |
| 731 | message += stdout; |
| 732 | } |
| 733 | |
| 734 | if (stderr && stderr.length > 0) { |
| 735 | message += stderr; |
| 736 | err = true; |
| 737 | } |
| 738 | |
| 739 | if (error) { |
| 740 | message += error.message; |
| 741 | err = true; |
| 742 | } |
| 743 | |
| 744 | if (err) { |
| 745 | channel.append(message); |
| 746 | channel.show(); |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | if (error) { |
| 751 | reject(error); |
| 752 | return; |
| 753 | } |
| 754 | |
| 755 | if (stderr && stderr.length > 0) { |
| 756 | reject(new Error(stderr)); |
| 757 | return; |
| 758 | } |
| 759 | |
| 760 | resolve(stdout); |
| 761 | }); |
| 762 | }); |
| 763 | } |
| 764 | |
| 765 | export interface ProcessReturnType { |
| 766 | succeeded: boolean; |
no test coverage detected