Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for both sf and sfdx env vars #857

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/commands/org/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class OrgOpenCommand extends SfCommand<OrgOpenOutput> {
this.conn = this.org.getConnection(flags['api-version']);

let url = await this.buildFrontdoorUrl();
const env = new Env();

if (flags['source-file']) {
url += `&retURL=${await this.generateFileUrl(flags['source-file'])}`;
Expand All @@ -83,7 +84,8 @@ export class OrgOpenCommand extends SfCommand<OrgOpenOutput> {
// TODO: better typings in sfdx-core for orgs read from auth files
const username = this.org.getUsername() as string;
const output = { orgId, url, username };
const containerMode = new Env().getBoolean('SFDX_CONTAINER_MODE');
// NOTE: Deliberate use of `||` here since getBoolean() defaults to false, and we need to consider both env vars.
const containerMode = env.getBoolean('SF_CONTAINER_MODE') || env.getBoolean('SFDX_CONTAINER_MODE');

// security warning only for --json OR --url-only OR containerMode
if (flags['url-only'] || Boolean(flags.json) || containerMode) {
Expand Down Expand Up @@ -115,7 +117,8 @@ export class OrgOpenCommand extends SfCommand<OrgOpenOutput> {
if (err instanceof Error) {
if (err.message.includes('timeout')) {
const domain = `https://${/https?:\/\/([^.]*)/.exec(url)?.[1]}.lightning.force.com`;
const timeout = new Duration(new Env().getNumber('SFDX_DOMAIN_RETRY', 240), Duration.Unit.SECONDS);
const domainRetryTimeout = env.getNumber('SF_DOMAIN_RETRY') ?? env.getNumber('SFDX_DOMAIN_RETRY', 240);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be the same ||?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No because env.getNumber() does not have a default value (like getBoolean() does) so if the env var is not set it returns undefined.

const timeout = new Duration(domainRetryTimeout, Duration.Unit.SECONDS);
const logger = await Logger.child(this.constructor.name);
logger.debug(`Did not find IP for ${domain} after ${timeout.seconds} seconds`);
throw new SfError(messages.getMessage('domainTimeoutError'), 'domainTimeoutError');
Expand Down
Loading