Skip to content

Commit

Permalink
Fixes prompting for entra app. Closes pnp#6498
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz committed Nov 20, 2024
1 parent 6c6be23 commit cd6f05b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/m365/base/AppCommand.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ describe('AppCommand', () => {
}
]
}));
sinon.stub(cli, 'handleMultipleResultsFound').resolves({ appIdIndex: 1 });
sinon.stub(cli, 'handleMultipleResultsFound').resolves({
"appId": "9c79078b-815e-4a3e-bb80-2aaf2d9e9b3d",
"name": "CLI app1"
});
sinon.stub(Command.prototype, 'action').resolves();

try {
Expand Down
9 changes: 6 additions & 3 deletions src/m365/base/AppCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ export default abstract class AppCommand extends Command {
}

if (this.m365rcJson.apps.length > 1) {
const resultAsKeyValuePair = formatting.convertArrayToHashTable('appIdIndex', this.m365rcJson.apps);
const result = await cli.handleMultipleResultsFound<{ appIdIndex: number }>(`Multiple Entra apps found in ${m365rcJsonPath}.`, resultAsKeyValuePair);
this.appId = ((this.m365rcJson as M365RcJson).apps as M365RcJsonApp[])[result.appIdIndex].appId;
this.m365rcJson.apps.forEach((app, index) => {
(app as any).appIdIndex = index;
});
const resultAsKeyValuePair = formatting.convertArrayToHashTable('appId', this.m365rcJson.apps);
const result = await cli.handleMultipleResultsFound<M365RcJsonApp>(`Multiple Entra apps found in ${m365rcJsonPath}.`, resultAsKeyValuePair);
this.appId = result.appId;
await super.action(logger, args);
}
}
Expand Down

0 comments on commit cd6f05b

Please sign in to comment.