diff --git a/package.json b/package.json index 642299d..253b854 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,15 @@ "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" + } } } ] diff --git a/src/extension.ts b/src/extension.ts index 949744c..bd7a43d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -20,7 +20,21 @@ const rpc = new RPCClient(config.get('clientID')!, statusBarIcon); export async function activate(context: ExtensionContext) { Logger.log('Discord Presence activated!'); - if (config.get('enabled')) { + let isWorkspaceExcluded = false; + const excludePatterns = config.get('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('enabled')) { statusBarIcon.show(); try { await rpc.login(); diff --git a/tsconfig.json b/tsconfig.json index c0860e9..8dbf839 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,10 @@ "declaration": true, "sourceMap": true, "removeComments": false, - "experimentalDecorators": true + "experimentalDecorators": true, + "typeRoots": [ + "node_modules/@types" + ] }, "include": [ "./src"