From e41db4876c6c6e1404b572b2f9f7fcd47a6b172e Mon Sep 17 00:00:00 2001 From: Cristian Dominguez Date: Mon, 16 May 2022 18:09:53 -0300 Subject: [PATCH] fix: update `no username` err from core v3 --- src/sfdxCommand.ts | 4 ++-- test/unit/sfdxCommand.test.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sfdxCommand.ts b/src/sfdxCommand.ts index 046650c..2d3d8fd 100644 --- a/src/sfdxCommand.ts +++ b/src/sfdxCommand.ts @@ -216,7 +216,7 @@ export abstract class SfdxCommand extends Command { } } catch (err) { if (this.statics.requiresUsername) { - if (err instanceof Error && (err.name === 'NoUsername' || err.name === 'AuthInfoCreationError')) { + if (err instanceof Error && (err.name === 'NoUsernameFoundError' || err.name === 'AuthInfoCreationError')) { throw messages.createError('error.RequiresUsername'); } throw err; @@ -240,7 +240,7 @@ export abstract class SfdxCommand extends Command { // Throw an error if the command requires a devhub and there is no targetdevhubusername // flag set and no defaultdevhubusername set. if (this.statics.requiresDevhubUsername && err instanceof Error) { - if (err.name === 'AuthInfoCreationError' || err.name === 'NoUsername') { + if (err.name === 'AuthInfoCreationError' || err.name === 'NoUsernameFoundError') { throw messages.createError('error.RequiresDevhubUsername'); } throw SfError.wrap(err); diff --git a/test/unit/sfdxCommand.test.ts b/test/unit/sfdxCommand.test.ts index 95c2364..9fb56dc 100644 --- a/test/unit/sfdxCommand.test.ts +++ b/test/unit/sfdxCommand.test.ts @@ -838,7 +838,7 @@ describe('SfdxCommand', () => { }); it('should throw when a username is required and org create fails', async () => { - $$.SANDBOX.stub(Org, 'create').throws('NoUsername'); + $$.SANDBOX.stub(Org, 'create').throws('NoUsernameFoundError'); class TestCommand extends BaseTestCommand {} TestCommand['requiresUsername'] = true; @@ -857,7 +857,7 @@ describe('SfdxCommand', () => { }); it('should emit a cmdError event when a command catches an error', async () => { - $$.SANDBOX.stub(Org, 'create').throws('NoUsername'); + $$.SANDBOX.stub(Org, 'create').throws('NoUsernameFoundError'); class TestCommand extends BaseTestCommand { public static varargs = true; } @@ -883,7 +883,7 @@ describe('SfdxCommand', () => { }); it('should NOT throw when supportsUsername and org create fails', async () => { - $$.SANDBOX.stub(Org, 'create').throws('NoUsername'); + $$.SANDBOX.stub(Org, 'create').throws('NoUsernameFoundError'); class TestCommand extends BaseTestCommand {} TestCommand['supportsUsername'] = true; @@ -907,7 +907,7 @@ describe('SfdxCommand', () => { }); it('should throw when a devhub username is required and org create fails', async () => { - $$.SANDBOX.stub(Org, 'create').throws('NoUsername'); + $$.SANDBOX.stub(Org, 'create').throws('NoUsernameFoundError'); class TestCommand extends BaseTestCommand {} TestCommand['requiresDevhubUsername'] = true; @@ -926,7 +926,7 @@ describe('SfdxCommand', () => { }); it('should NOT throw when supportsDevhubUsername and org create fails', async () => { - $$.SANDBOX.stub(Org, 'create').throws('NoUsername'); + $$.SANDBOX.stub(Org, 'create').throws('NoUsernameFoundError'); class TestCommand extends BaseTestCommand {} TestCommand['supportsDevhubUsername'] = true;