diff --git a/src/commands/org/login/web.ts b/src/commands/org/login/web.ts index 509fdc24..965aee2f 100644 --- a/src/commands/org/login/web.ts +++ b/src/commands/org/login/web.ts @@ -73,7 +73,7 @@ export default class LoginWeb extends SfCommand { public async run(): Promise { const { flags } = await this.parse(LoginWeb); - if (isSFDXContainerMode()) { + if (isContainerMode()) { throw new SfError(messages.getMessage('deviceWarning'), 'DEVICE_WARNING'); } @@ -121,7 +121,7 @@ export default class LoginWeb extends SfCommand { } } -const isSFDXContainerMode = (): boolean => { +const isContainerMode = (): boolean => { const env = new Env(); - return env.getBoolean('SFDX_CONTAINER_MODE'); + return env.getBoolean('SF_CONTAINER_MODE', env.getBoolean('SFDX_CONTAINER_MODE')); }; diff --git a/test/commands/org/login/login.web.test.ts b/test/commands/org/login/login.web.test.ts index 89f8f33c..3de3d761 100644 --- a/test/commands/org/login/login.web.test.ts +++ b/test/commands/org/login/login.web.test.ts @@ -115,6 +115,16 @@ describe('org:login:web', () => { expect(err.name).to.equal('DEVICE_WARNING'); } }); + it('should throw device warning error when in container mode (SF_CONTAINER_MODE)', async () => { + stubMethod($$.SANDBOX, Env.prototype, 'getBoolean').withArgs('SF_CONTAINER_MODE').returns(true); + const login = await createNewLoginCommand([], false, undefined); + try { + await login.run(); + } catch (error) { + const err = error as SfError; + expect(err.name).to.equal('DEVICE_WARNING'); + } + }); it('should prompt for client secret when clientid is present', async () => { const login = await createNewLoginCommand(['--client-id', 'CoffeeBeans'], false, undefined);