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

Commit

Permalink
fix: do not error in empty workspaces
Browse files Browse the repository at this point in the history
Do not spam error output to users if there is no workspace available

Closes #142
  • Loading branch information
KnisterPeter committed Aug 10, 2017
1 parent 9c6d363 commit 5b1769c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![Marketplace Version](https://vsmarketplacebadge.apphb.com/version/knisterpeter.vscode-github.svg)](https://marketplace.visualstudio.com/items?itemName=KnisterPeter.vscode-github)
[![Installs](https://vsmarketplacebadge.apphb.com/installs/knisterpeter.vscode-github.svg)](https://marketplace.visualstudio.com/items?itemName=KnisterPeter.vscode-github)
[![Travis](https://img.shields.io/travis/KnisterPeter/vscode-github.svg)](https://travis-ci.org/KnisterPeter/vscode-github)
[![Coverage Status](https://coveralls.io/repos/github/KnisterPeter/vscode-github/badge.svg?branch=master)](https://coveralls.io/github/KnisterPeter/vscode-github?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/KnisterPeter/vscode-github.svg)](https://greenkeeper.io/)

This vscode extension integrates with GitHub.
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ class Extension {
context.subscriptions.push(this.channel);
this.channel.appendLine('Visual Studio Code GitHub Extension');

this.githubManager = new GitHubManager(this.cwd, this.channel);
this.statusBarManager = new StatusBarManager(context, this.cwd, this.githubManager, this.channel);

const tokens = context.globalState.get<Tokens>('tokens');
if (tokens) {
this.githubManager.connect(tokens);
}
this.checkVersionAndToken(context, tokens);

context.subscriptions.push(
Expand All @@ -60,6 +54,15 @@ class Extension {
vscode.commands.registerCommand('vscode-github.browseOpenIssue', this.wrapCommand(this.browseOpenIssue)),
vscode.commands.registerCommand('vscode-github.browseCurrentFile', this.wrapCommand(this.browseCurrentFile))
);

if (!vscode.workspace.rootPath) {
return;
}
this.githubManager = new GitHubManager(this.cwd, this.channel);
this.statusBarManager = new StatusBarManager(context, this.cwd, this.githubManager, this.channel);
if (tokens) {
this.githubManager.connect(tokens);
}
} catch (e) {
this.logAndShowError(e);
throw e;
Expand Down Expand Up @@ -104,7 +107,7 @@ class Extension {

private wrapCommand<T>(command: T): T {
const wrap: any = (...args: any[]) => {
if (this.githubManager.connected && this.cwd) {
if (this.githubManager && this.githubManager.connected && this.cwd) {
try {
return (command as any).apply(this, args);
} catch (e) {
Expand Down

0 comments on commit 5b1769c

Please sign in to comment.