Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: warn when attempting to unset a global config without flag #346

Merged
merged 5 commits into from
Aug 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: detect local and global scenario
  • Loading branch information
WillieRuemmele committed Aug 10, 2023
commit 8db2c93faa8173a6da7c72e947229f7ea3130102
4 changes: 3 additions & 1 deletion src/commands/config/unset.ts
Original file line number Diff line number Diff line change
@@ -37,14 +37,16 @@ export class UnSet extends SfCommand<SetOrUnsetConfigCommandResult> {
throw messages.createError('error.NoConfigKeysFound');
}
const config = await Config.create(Config.getDefaultOptions(flags.global));
const globalConfig = await Config.create(Config.getDefaultOptions(true));

await globalConfig.read();
await config.read();
for (const key of argv as string[]) {
try {
const resolvedName = this.configAggregator.getPropertyMeta(key)?.newKey ?? key;
config.unset(resolvedName);

if (!flags.global && this.configAggregator.getLocation(resolvedName) === 'Global') {
if (!flags.global && globalConfig.has(resolvedName)) {
// If the config var is still set globally after an unset and the user didn't have the `--global` flag set, warn them.
this.warn(messages.getMessage('unsetGlobalWarning', [resolvedName]));
}