Add Workspace Exclusion Regex Support (#220)
This commit is contained in:
parent
4c01c27b09
commit
983207ae48
3 changed files with 28 additions and 3 deletions
|
@ -138,6 +138,14 @@
|
|||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Decides whether to display elapsed time for a workspace or a single file"
|
||||
},
|
||||
"discord.workspaceExcludePatterns": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"default": [],
|
||||
"description": "Patterns of workspaces to ignore"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,21 @@ const rpc = new RPCClient(config.get<string>('clientID')!, statusBarIcon);
|
|||
export async function activate(context: ExtensionContext) {
|
||||
Logger.log('Discord Presence activated!');
|
||||
|
||||
if (config.get<boolean>('enabled')) {
|
||||
let isWorkspaceExcluded = false;
|
||||
const excludePatterns = config.get<string[]>('workspaceExcludePatterns');
|
||||
if (excludePatterns && excludePatterns.length > 0) {
|
||||
for (const pattern of excludePatterns) {
|
||||
const regex = new RegExp(pattern);
|
||||
const folders = workspace.workspaceFolders;
|
||||
if (!folders) break;
|
||||
if (folders.some((folder) => regex.test(folder.uri.fsPath))) {
|
||||
isWorkspaceExcluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWorkspaceExcluded && config.get<boolean>('enabled')) {
|
||||
statusBarIcon.show();
|
||||
try {
|
||||
await rpc.login();
|
||||
|
|
|
@ -13,7 +13,10 @@
|
|||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"removeComments": false,
|
||||
"experimentalDecorators": true
|
||||
"experimentalDecorators": true,
|
||||
"typeRoots": [
|
||||
"node_modules/@types"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"./src"
|
||||
|
|
Loading…
Reference in a new issue