Skip to content

Commit

Permalink
Merge pull request #3 from bmalehorn/hide-codeowners
Browse files Browse the repository at this point in the history
hide status bar item when no CODEOWNERS file
  • Loading branch information
jasonnutter committed Jul 25, 2019
2 parents 71838dc + 6495dd7 commit e5dfe2c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ const getOwners = () => {
uri: { fsPath: workspacePath }
} = vscode.workspace.getWorkspaceFolder(uri);

const folder = new Codeowners(workspacePath);
let folder;
try {
folder = new Codeowners(workspacePath);
} catch {
// no CODEOWNERS file
return null;
}

const file = fileName.split(workspacePath)[1];

Expand All @@ -40,6 +46,11 @@ const activate = context => {
vscode.window.onDidChangeActiveTextEditor(() => {
const owners = getOwners();

if (!owners) {
statusBarItem.hide();
return;
}

if (owners.length > 2) {
statusBarItem.text = `CODEOWNERS: ${owners[0]} & ${owners.length - 1} others`;
} else if (owners.length === 2) {
Expand Down

0 comments on commit e5dfe2c

Please sign in to comment.