How to use the @salesforce/core.ConfigFile 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 msrivastav13 / DX-Code-Companion / src / services / config.ts View on Github external
public static async getDefaultUsername() {
        if(vscode.workspace && vscode.workspace.workspaceFolders) {
            const rootPath = vscode.workspace.workspaceFolders[0].uri.fsPath;
            const myLocalConfig = await sfcore.ConfigFile.create({
                isGlobal: false,
                rootFolder: path.join(rootPath, '.sfdx'),
                filename: 'sfdx-config.json'
            });
            const localValue = myLocalConfig.get('defaultusername');
            let defaultusername = await sfcore.Aliases.fetch(JSON.stringify(localValue).replace(/\"/g, ''));
            return defaultusername;
        }
    }
}