Skip to content

Commit

Permalink
fix: allow auth:sfdxurl:store to use a json file
Browse files Browse the repository at this point in the history
  • Loading branch information
RodEsp committed Mar 12, 2021
1 parent d09b38b commit a9f0300
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/commands/auth/sfdxurl/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ export default class Store extends SfdxCommand {
public async run(): Promise<AuthFields> {
if (await Prompts.shouldExitCommand(this.ux, this.flags.noprompt)) return {};

const sfdxAuthUrl = await fs.readFile(this.flags.sfdxurlfile, 'utf8');
let sfdxAuthUrl;
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
if (this.flags.sfdxurlfile.endsWith('json')) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
sfdxAuthUrl = await fs.readJson(this.flags.sfdxurlfile);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
sfdxAuthUrl = sfdxAuthUrl.sfdxAuthUrl;
} else {
sfdxAuthUrl = await fs.readFile(this.flags.sfdxurlfile, 'utf8');
}
const oauth2Options = AuthInfo.parseSfdxAuthUrl(sfdxAuthUrl);
const authInfo = await AuthInfo.create({ oauth2Options });
await authInfo.save();
Expand Down

0 comments on commit a9f0300

Please sign in to comment.