fix: changing files

This commit is contained in:
iCrawl 2021-04-14 14:56:15 +02:00
parent 6c1bcb6524
commit 7cefeb2af8
No known key found for this signature in database
GPG key ID: 1AB888B16355FBB2
4 changed files with 12 additions and 21 deletions

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "discord-vscode", "name": "discord-vscode",
"version": "5.5.0", "version": "5.6.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View file

@ -1,7 +1,7 @@
{ {
"name": "discord-vscode", "name": "discord-vscode",
"displayName": "Discord Presence", "displayName": "Discord Presence",
"version": "5.5.0", "version": "5.6.0",
"description": "Update your discord status with a rich presence.", "description": "Update your discord status with a rich presence.",
"private": true, "private": true,
"author": { "author": {

View file

@ -1,21 +1,11 @@
const { Client } = require('discord-rpc'); // eslint-disable-line const { Client } = require('discord-rpc'); // eslint-disable-line
import { import { commands, ExtensionContext, StatusBarAlignment, StatusBarItem, window, workspace, debug } from 'vscode';
commands,
ExtensionContext,
StatusBarAlignment,
StatusBarItem,
window,
workspace,
extensions,
debug,
} from 'vscode';
import throttle from 'lodash-es/throttle'; import throttle from 'lodash-es/throttle';
import { activity } from './activity'; import { activity } from './activity';
import { CLIENT_ID, CONFIG_KEYS } from './constants'; import { CLIENT_ID, CONFIG_KEYS } from './constants';
import { GitExtension } from './git';
import { log, LogLevel } from './logger'; import { log, LogLevel } from './logger';
import { getConfig } from './util'; import { getConfig, getGit } from './util';
const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left); const statusBarIcon: StatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left);
statusBarIcon.text = '$(pulse) Connecting to Discord...'; statusBarIcon.text = '$(pulse) Connecting to Discord...';
@ -173,12 +163,7 @@ export async function activate(context: ExtensionContext) {
} }
}); });
try { await getGit();
const gitExtension = extensions.getExtension<GitExtension>('vscode.git');
if (!gitExtension?.isActive) {
await gitExtension?.activate();
}
} catch {}
} }
export async function deactivate() { export async function deactivate() {

View file

@ -5,6 +5,8 @@ import { KNOWN_EXTENSIONS, KNOWN_LANGUAGES } from './constants';
import { API, GitExtension } from './git'; import { API, GitExtension } from './git';
import { log, LogLevel } from './logger'; import { log, LogLevel } from './logger';
let git: API | null | undefined;
type WorkspaceExtensionConfiguration = WorkspaceConfiguration & { type WorkspaceExtensionConfiguration = WorkspaceConfiguration & {
enabled: boolean; enabled: boolean;
detailsIdling: string; detailsIdling: string;
@ -63,7 +65,10 @@ export function resolveFileIcon(document: TextDocument) {
} }
export async function getGit() { export async function getGit() {
let git: API | undefined; if (git || git === null) {
return git;
}
try { try {
log(LogLevel.Debug, 'Loading git extension'); log(LogLevel.Debug, 'Loading git extension');
const gitExtension = extensions.getExtension<GitExtension>('vscode.git'); const gitExtension = extensions.getExtension<GitExtension>('vscode.git');
@ -73,6 +78,7 @@ export async function getGit() {
} }
git = gitExtension?.exports.getAPI(1); git = gitExtension?.exports.getAPI(1);
} catch (error) { } catch (error) {
git = null;
log(LogLevel.Error, `Failed to load git extension, is git installed?; ${error as string}`); log(LogLevel.Error, `Failed to load git extension, is git installed?; ${error as string}`);
} }