Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
fix: update no username err from core v3
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed May 16, 2022
1 parent 153028c commit e41db48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/sfdxCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions test/unit/sfdxCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit e41db48

Please sign in to comment.