Skip to content

Commit

Permalink
refactor: kit.mapKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Feb 8, 2021
1 parent 8b3a6f9 commit 6c36392
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/commands/force/user/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
UserFields,
} from '@salesforce/core';
import { QueryResult } from 'jsforce';
import { omit } from '@salesforce/kit';
import { omit, mapKeys } from '@salesforce/kit';
import { getString, Dictionary, isArray } from '@salesforce/ts-types';
import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';

Expand All @@ -44,13 +44,6 @@ const permsetsStringToArray = (fieldsPermsets: string | string[]): string[] => {
: fieldsPermsets.split(',').map((item) => item.replace("'", '').trim());
};

const lowercaseAllKeys = (input: Record<string, unknown>): Record<string, unknown> => {
return Object.keys(input).reduce(function (accum, key) {
accum[key.toLowerCase()] = input[key];
return accum;
}, {});
};

const standardizePasswordToBoolean = (input: unknown): boolean => {
if (typeof input === 'boolean') {
return input;
Expand Down Expand Up @@ -171,7 +164,7 @@ export class UserCreateCommand extends SfdxCommand {
return {
orgId: this.org.getOrgId(),
permissionSetAssignments: permsetsStringToArray(permsets),
fields: { ...lowercaseAllKeys(fieldsWithoutPermsets) },
fields: { ...mapKeys(fieldsWithoutPermsets, (value, key) => key.toLowerCase()) },
};
}

Expand Down

0 comments on commit 6c36392

Please sign in to comment.