Skip to content

Commit ac3c815

Browse files
committed
Prevent prompting for api key when already set in settings json
1 parent 1c118a7 commit ac3c815

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export class Options {
280280
}
281281
}
282282

283-
private getApiKeyFromEditor(): string {
283+
public getApiKeyFromEditor(): string {
284284
return vscode.workspace.getConfiguration().get('wakatime.apiKey') || '';
285285
}
286286

src/wakatime.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ export class WakaTime {
369369
}
370370

371371
public async openDashboardWebsite(): Promise<void> {
372-
const url = (await this.options.getApiUrl(true)).replace('/api/v1', '').replace('://api.', '://');
372+
const url = (await this.options.getApiUrl(true))
373+
.replace('/api/v1', '')
374+
.replace('://api.', '://');
373375
vscode.env.openExternal(vscode.Uri.parse(url));
374376
}
375377

@@ -567,7 +569,14 @@ export class WakaTime {
567569
if (this.isMetricsEnabled) args.push('--metrics');
568570

569571
const apiKey = this.options.getApiKeyFromEnv();
570-
if (!Utils.apiKeyInvalid(apiKey)) args.push('--key', Utils.quote(apiKey));
572+
if (!Utils.apiKeyInvalid(apiKey)) {
573+
args.push('--key', Utils.quote(apiKey));
574+
} else {
575+
const apiKeyFromSettings = this.options.getApiKeyFromEditor();
576+
if (!Utils.apiKeyInvalid(apiKeyFromSettings)) {
577+
args.push('--key', Utils.quote(apiKeyFromSettings));
578+
}
579+
}
571580

572581
const apiUrl = await this.options.getApiUrl();
573582
if (apiUrl) args.push('--api-url', Utils.quote(apiUrl));

0 commit comments

Comments
 (0)