Skip to content

Commit

Permalink
Merge pull request #45 from salesforcecli/wr/passwordJsonOutput
Browse files Browse the repository at this point in the history
fix: object for one user, array for multiple [skip-validate-pr]
  • Loading branch information
shetzel authored Feb 5, 2021
2 parents 898886e + e37597e commit 65842e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/commands/force/user/password/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class UserPasswordGenerateCommand extends SfdxCommand {
private usernames: string[];
private passwordData: PasswordData[] = [];

public async run(): Promise<PasswordData[]> {
public async run(): Promise<PasswordData[] | PasswordData> {
this.usernames = (this.flags.onbehalfof as string[]) ?? [this.org.getUsername()];

for (const aliasOrUsername of this.usernames) {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/user/password/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]', password: 'abc' }];
const expected = { username: '[email protected]', password: 'abc' };
const result = JSON.parse(ctx.stdout).result;
expect(result).to.deep.equal(expected);
expect(authInfoStub.update.callCount).to.equal(1);
Expand Down

0 comments on commit 65842e4

Please sign in to comment.