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",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Decides whether to display elapsed time for a workspace or a single file"
|
"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) {
|
export async function activate(context: ExtensionContext) {
|
||||||
Logger.log('Discord Presence activated!');
|
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();
|
statusBarIcon.show();
|
||||||
try {
|
try {
|
||||||
await rpc.login();
|
await rpc.login();
|
||||||
|
|
|
@ -13,7 +13,10 @@
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"experimentalDecorators": true
|
"experimentalDecorators": true,
|
||||||
|
"typeRoots": [
|
||||||
|
"node_modules/@types"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"./src"
|
"./src"
|
||||||
|
|
Loading…
Reference in a new issue