forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathpythonDebugger.ts
More file actions
30 lines (25 loc) · 873 Bytes
/
pythonDebugger.ts
File metadata and controls
30 lines (25 loc) · 873 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { extensions } from 'vscode';
interface IPythonDebuggerExtensionApi {
debug: {
getDebuggerPackagePath(): Promise<string>;
};
}
async function activateExtension() {
const extension = extensions.getExtension('ms-python.debugpy');
if (extension) {
if (!extension.isActive) {
await extension.activate();
}
}
return extension;
}
async function getPythonDebuggerExtensionAPI(): Promise<IPythonDebuggerExtensionApi | undefined> {
const extension = await activateExtension();
return extension?.exports as IPythonDebuggerExtensionApi;
}
export async function getDebugpyPath(): Promise<string> {
const api = await getPythonDebuggerExtensionAPI();
return api?.debug.getDebuggerPackagePath() ?? '';
}