Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/git/src/git-base.ts
3314 views
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
6
import { extensions } from 'vscode';
7
import { API as GitBaseAPI, GitBaseExtension } from './typings/git-base';
8
9
export class GitBaseApi {
10
11
private static _gitBaseApi: GitBaseAPI | undefined;
12
13
static getAPI(): GitBaseAPI {
14
if (!this._gitBaseApi) {
15
const gitBaseExtension = extensions.getExtension<GitBaseExtension>('vscode.git-base')!.exports;
16
const onDidChangeGitBaseExtensionEnablement = (enabled: boolean) => {
17
this._gitBaseApi = enabled ? gitBaseExtension.getAPI(1) : undefined;
18
};
19
20
gitBaseExtension.onDidChangeEnablement(onDidChangeGitBaseExtensionEnablement);
21
onDidChangeGitBaseExtensionEnablement(gitBaseExtension.enabled);
22
23
if (!this._gitBaseApi) {
24
throw new Error('vscode.git-base extension is not enabled.');
25
}
26
}
27
28
return this._gitBaseApi;
29
}
30
}
31
32