-
Notifications
You must be signed in to change notification settings - Fork 542
Expand file tree
/
Copy pathGenerateBugReport.ts
More file actions
57 lines (51 loc) · 1.98 KB
/
GenerateBugReport.ts
File metadata and controls
57 lines (51 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import vscode = require("vscode");
import child_process = require("child_process");
import { SessionManager } from "../session";
const issuesUrl = "https://github.com/PowerShell/vscode-powershell/issues/new?";
export class GenerateBugReportFeature implements vscode.Disposable {
private command: vscode.Disposable;
constructor(private sessionManager: SessionManager) {
this.command = vscode.commands.registerCommand(
"PowerShell.GenerateBugReport",
async () => {
const params = [
"labels=Issue-Bug",
"template=bug-report.yml",
"powershell-version=" + this.getRuntimeInfo(),
"vscode-version=" + vscode.version + "\n" + process.arch,
"extension-version=" +
sessionManager.Publisher +
"." +
sessionManager.HostName +
"@" +
sessionManager.HostVersion,
];
const url = vscode.Uri.parse(
issuesUrl + encodeURIComponent(params.join("&")),
);
await vscode.env.openExternal(url);
},
);
}
public dispose(): void {
this.command.dispose();
}
private getRuntimeInfo(): string {
if (this.sessionManager.PowerShellExeDetails === undefined) {
return "Session's PowerShell details are unknown!";
}
const child = child_process.spawnSync(
this.sessionManager.PowerShellExeDetails.exePath,
[
"-NoProfile",
"-NoLogo",
"-Command",
"$PSVersionTable | Out-String",
],
);
// Replace semicolons as they'll cause the URI component to truncate
return child.stdout.toString().trim().replace(";", ",");
}
}