Skip to content

Commit

Permalink
Lazy import of keytar (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyuu-jin authored Jan 8, 2025
1 parent 5564736 commit 2010450
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/keys.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import keytar from 'keytar';
import * as inquirer from 'inquirer';

export async function select() {
const credentials = await keytar.findCredentials('VALIST')
const keytar = await import('keytar').then(module => module.default || module);
const inquirer = await import('inquirer');

const credentials = await keytar.findCredentials('VALIST');
if (credentials.length === 0) {
throw new Error('no accounts found. use import to add an account.')
throw new Error('No accounts found. Use import to add an account.');
}

const { account } = await inquirer.prompt([{
name: 'account',
message: 'select an account',
message: 'Select an account',
type: 'list',
choices: credentials.map(c => ({ name: c.account, value: c.password })),
}]);

return account
}
return account;
}

0 comments on commit 2010450

Please sign in to comment.