Skip to content

Commit 945e53a

Browse files
committed
Defer loading of keytar (fixes microsoft#33998)
1 parent 1488aaf commit 945e53a

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/vs/platform/credentials/node/credentialsService.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,29 @@
66

77
import { TPromise } from 'vs/base/common/winjs.base';
88
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
9-
import * as keytar from 'keytar';
109

1110
export class CredentialsService implements ICredentialsService {
1211

1312
_serviceBrand: any;
1413

1514
readSecret(service: string, account: string): TPromise<string | undefined> {
16-
return TPromise.wrap(keytar.getPassword(service, account))
15+
return this.getKeytar()
16+
.then(keytar => TPromise.wrap(keytar.getPassword(service, account)))
1717
.then(result => result === null ? undefined : result);
1818
}
1919

2020
writeSecret(service: string, account: string, secret: string): TPromise<void> {
21-
return TPromise.wrap(keytar.setPassword(service, account, secret));
21+
return this.getKeytar()
22+
.then(keytar => TPromise.wrap(keytar.setPassword(service, account, secret)));
2223
}
2324

2425
deleteSecret(service: string, account: string): TPromise<boolean> {
25-
return TPromise.wrap(keytar.deletePassword(service, account));
26+
return this.getKeytar()
27+
.then(keytar => TPromise.wrap(keytar.deletePassword(service, account)));
28+
}
29+
30+
private getKeytar() {
31+
// Avoids https://github.com/Microsoft/vscode/issues/33998
32+
return TPromise.wrap(import('keytar'));
2633
}
2734
}

0 commit comments

Comments
 (0)