From e37597efc00208d89e904d85db5e6eac3213f26a Mon Sep 17 00:00:00 2001 From: Willie Ruemmele Date: Fri, 5 Feb 2021 15:01:13 -0700 Subject: [PATCH] fix: object for one user, array for multiple --- src/commands/force/user/password/generate.ts | 4 ++-- test/commands/user/password/generate.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands/force/user/password/generate.ts b/src/commands/force/user/password/generate.ts index b230efd2..90fc5345 100644 --- a/src/commands/force/user/password/generate.ts +++ b/src/commands/force/user/password/generate.ts @@ -32,7 +32,7 @@ export class UserPasswordGenerateCommand extends SfdxCommand { private usernames: string[]; private passwordData: PasswordData[] = []; - public async run(): Promise { + public async run(): Promise { this.usernames = (this.flags.onbehalfof as string[]) ?? [this.org.getUsername()]; for (const aliasOrUsername of this.usernames) { @@ -87,7 +87,7 @@ export class UserPasswordGenerateCommand extends SfdxCommand { this.print(); - return this.passwordData; + return this.passwordData.length === 1 ? this.passwordData[0] : this.passwordData; } private print(): void { diff --git a/test/commands/user/password/generate.test.ts b/test/commands/user/password/generate.test.ts index 0403c2bf..dbaf5691 100644 --- a/test/commands/user/password/generate.test.ts +++ b/test/commands/user/password/generate.test.ts @@ -78,7 +78,7 @@ describe('force:user:password:generate', () => { .stdout() .command(['force:user:password:generate', '--json']) .it('should generate a new password for the default user', (ctx) => { - const expected = [{ username: 'defaultusername@test.com', password: 'abc' }]; + const expected = { username: 'defaultusername@test.com', password: 'abc' }; const result = JSON.parse(ctx.stdout).result; expect(result).to.deep.equal(expected); expect(authInfoStub.update.callCount).to.equal(1);