How to use the @salesforce/core.AuthInfo.listAllAuthFiles function in @salesforce/core

To help you get started, we’ve selected a few @salesforce/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github forcedotcom / salesforcedx-vscode / packages / salesforcedx-vscode-core / src / orgPicker / orgList.ts View on Github external
public async getAuthInfoObjects() {
    const authFilesArray = await AuthInfo.listAllAuthFiles().catch(err => null);

    if (authFilesArray === null || authFilesArray.length === 0) {
      return null;
    }
    const authInfoObjects: FileInfo[] = [];
    for (const username of authFilesArray) {
      try {
        const filePath = path.join(
          await AuthInfoConfig.resolveRootFolder(true),
          '.sfdx',
          username
        );
        const fileData = readFileSync(filePath, 'utf8');
        authInfoObjects.push(JSON.parse(fileData));
      } catch (e) {
        console.log(e);