Skip to content

Commit

Permalink
fix: changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jan 29, 2021
1 parent 6c63000 commit b0a24a5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/commands/force/org/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { URL } from 'url';

import { flags, FlagsConfig, SfdxCommand } from '@salesforce/command';
import { Messages, Org, MyDomainResolver, SfdxError, sfdc } from '@salesforce/core';
import { Env, toNumber, Duration } from '@salesforce/kit';
import { Env, Duration } from '@salesforce/kit';
import { openUrl } from '../../../shared/utils';

Messages.importMessagesDirectory(__dirname);
Expand Down Expand Up @@ -39,7 +39,7 @@ export class OrgOpenCommand extends SfdxCommand {
const username = this.org.getUsername();
const output = { orgId, url, username };

if (new Env().getString('SFDX_CONTAINER_MODE') ? true : false) {
if (new Env().getBoolean('SFDX_CONTAINER_MODE')) {
// instruct the user that they need to paste the URL into the browser
this.ux.styledHeader('Action Required!');
this.ux.log(messages.getMessage('containerAction', [orgId, url]));
Expand All @@ -62,14 +62,13 @@ export class OrgOpenCommand extends SfdxCommand {
const conn = this.org.getConnection();
const accessToken = conn.accessToken;
const instanceUrl = this.org.getField(Org.Fields.INSTANCE_URL) as string;
const instanceUrlClean = instanceUrl.endsWith('/') ? instanceUrl.substr(0, instanceUrl.length) : instanceUrl;

const instanceUrlClean = instanceUrl.replace(/\/$/, '');
return `${instanceUrlClean}/secur/frontdoor.jsp?sid=${accessToken}`;
}

private async checkLightningDomain(url: string): Promise<void> {
const domain = `https://${/https?:\/\/([^.]*)/.exec(url)[1]}.lightning.force.com`;
const timeout = new Duration(toNumber(new Env().getString('SFDX_DOMAIN_RETRY', '240')), Duration.Unit.SECONDS);
const timeout = new Duration(new Env().getNumber('SFDX_DOMAIN_RETRY', 240), Duration.Unit.SECONDS);
if (sfdc.isInternalUrl(domain) || timeout.seconds === 0) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export const camelCaseToTitleCase = (text: string): string => {
};

export const openUrl = async (url: string): Promise<ChildProcess> => {
return open(url, { wait: false });
return open(url);
};
6 changes: 0 additions & 6 deletions test/commands/force/org/list.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
Expand Down

0 comments on commit b0a24a5

Please sign in to comment.