Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
feat: check the existence of git executable
Browse files Browse the repository at this point in the history
  • Loading branch information
KnisterPeter committed Sep 4, 2017
1 parent 9e3fda4 commit 6eaa948
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { TSDI, component, inject, initialize } from 'tsdi';
import * as vscode from 'vscode';

import { CommandManager } from './command-manager';
import { checkExistence } from './git';
import { GitHubError } from './github';
import { GitHubManager, Tokens } from './github-manager';

Expand All @@ -23,7 +24,7 @@ export class Extension {
private githubManager: GitHubManager;

@initialize
protected init(): void {
protected async init(): Promise<void> {
try {
this.migrateToken(this.context);
this.channel.appendLine('Visual Studio Code GitHub Extension');
Expand All @@ -35,6 +36,7 @@ export class Extension {
if (!vscode.workspace.workspaceFolders) {
return;
}
await checkExistence(vscode.workspace.workspaceFolders[0].uri.fsPath);
if (tokens) {
this.githubManager.connect(tokens);
}
Expand Down
9 changes: 9 additions & 0 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import { readFile, unlink } from 'sander';
import { parse } from 'url';
import * as vscode from 'vscode';

export async function checkExistence(cwd: string): Promise<boolean> {
try {
await execa('git', ['--version'], {cwd});
return true;
} catch (e) {
return false;
}
}

function getRemoteName(): string {
return vscode.workspace.getConfiguration('github').get('remoteName', 'origin');
}
Expand Down

0 comments on commit 6eaa948

Please sign in to comment.