Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private openConfigFile(configfolder: string): Promise> {
this.configfolder = configfolder;
if (!this.configfolder) {
this.configfolder = ".";
}
return ConfigFile.create({
filename: "ETCopyData.json",
isGlobal: false,
isState: false,
rootFolder: this.configfolder,
});
}
public async setGlobalDefaultDevHub(newUsername: string): Promise {
const homeDirectory = homedir();
const globalConfig = await ConfigFile.create({
isGlobal: true,
rootFolder: homeDirectory,
filename: SFDX_CONFIG_FILE
});
globalConfig.set(DEFAULT_DEV_HUB_USERNAME_KEY, newUsername);
await globalConfig.write();
}
}
public static async getConfigValue(
key: string,
source?: ConfigSource.Global | ConfigSource.Local
): Promise {
if (isUndefined(source) || source === ConfigSource.Local) {
try {
const rootPath = getRootWorkspacePath();
const myLocalConfig = await ConfigFile.create({
isGlobal: false,
rootFolder: path.join(rootPath, '.sfdx'),
filename: 'sfdx-config.json'
});
const localValue = myLocalConfig.get(key);
if (!isNullOrUndefined(localValue)) {
return localValue;
}
} catch (err) {
telemetryService.sendException('get_config_value_local', err.message);
return undefined;
}
}
if (isUndefined(source) || source === ConfigSource.Global) {
try {
const aggregator = await ConfigAggregator.create();