Skip to content

Commit 599794b

Browse files
committed
use child process promise
1 parent 7b1c30d commit 599794b

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
},
7070
"dependencies": {
7171
"async-file": "2.0.2",
72+
"child-process-promise": "^2.2.1",
7273
"fs-extra": "5.0.0",
7374
"http-proxy-agent": "2.1.0",
7475
"https-proxy-agent": "2.2.1",

src/features/generateBugReport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from "vscode";
7-
import cp = require("child_process");
7+
import { getDotnetInfo } from "./getdotnetInfo";
88

99
const extensionId = 'ms-vscode.csharp';
1010
const extension = vscode.extensions.getExtension(extensionId);
@@ -18,7 +18,7 @@ let extensions = vscode.extensions.all
1818
extensions.sort(sortExtensions);
1919

2020
export default async function generateBugReport() {
21-
const dotnetInfo = cp.execSync("dotnet --info");
21+
const dotnetInfo = await getDotnetInfo();
2222

2323
const body = encodeURIComponent(`## Issue Description ##
2424
## Steps to Reproduce ##

src/features/getdotnetInfo.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
import * as cp from "child-process-promise";
6+
7+
export async function getDotnetInfo(): Promise<string> {
8+
try {
9+
let result = await cp.exec("dotnet --info");
10+
return result.stdout;
11+
}
12+
catch{
13+
return "Dotnet info could not be obtained";
14+
}
15+
}

typings/child-process-promise.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
declare module 'child-process-promise' {
2+
3+
import { ChildProcess, ExecOptions } from "child_process";
4+
export function exec(command: string, options?: ExecOptions): Promise<Result>;
5+
6+
export interface Result{
7+
childProcess: ChildProcess;
8+
stdout: string;
9+
stdErr: string;
10+
}
11+
}

0 commit comments

Comments
 (0)