From 6c36392c6ce886a304018b48d4f6309270be0992 Mon Sep 17 00:00:00 2001 From: mshanemc Date: Mon, 8 Feb 2021 13:37:15 -0600 Subject: [PATCH] refactor: kit.mapKeys --- src/commands/force/user/create.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/commands/force/user/create.ts b/src/commands/force/user/create.ts index 7add7827..af4457b4 100644 --- a/src/commands/force/user/create.ts +++ b/src/commands/force/user/create.ts @@ -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'; @@ -44,13 +44,6 @@ const permsetsStringToArray = (fieldsPermsets: string | string[]): string[] => { : fieldsPermsets.split(',').map((item) => item.replace("'", '').trim()); }; -const lowercaseAllKeys = (input: Record): Record => { - 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; @@ -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()) }, }; }