Skip to content

Commit

Permalink
fix: don't display "undefined" when no profiles exists (twilio#92)
Browse files Browse the repository at this point in the history
If you've not created a profile yet and attempt to run a command that requires auth, you would see that the profile "undefined" could not be found. This change just updates the wording to indicate that a profile could not be found to use.

Relates to twilio/twilio-cli#148
  • Loading branch information
childish-sambino committed Jun 16, 2020
1 parent 8284a4e commit e753fcd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/base-commands/twilio-client-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class TwilioClientCommand extends BaseCommand {
};

if (!this.currentProfile) {
this.logger.error(`Could not find profile "${this.flags.profile}".`);
const profileName = this.flags.profile ? ` "${this.flags.profile}"` : '';
this.logger.error(`Could not find profile${profileName}.`);
reportUnconfigured('create', '\n\n' + HELP_ENVIRONMENT_VARIABLES);
}

Expand Down
4 changes: 2 additions & 2 deletions test/base-commands/twilio-client-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('base-commands', () => {
setUpTest(['-l', 'debug'], { setUpUserConfig: () => 0 })
.exit(1)
.it('should fail for a non-existent active profile', ctx => {
expect(ctx.stderr).to.contain('Could not find profile');
expect(ctx.stderr).to.contain('Could not find profile.');
expect(ctx.stderr).to.contain('To create the profile, run:');
expect(ctx.stderr).to.contain('twilio profiles:create');
expect(ctx.stderr).to.contain('TWILIO_ACCOUNT_SID');
Expand All @@ -94,7 +94,7 @@ describe('base-commands', () => {
setUpTest(['-p', 'alt', '-l', 'debug'])
.exit(1)
.it('should fail for a non-existent profile', ctx => {
expect(ctx.stderr).to.contain('Could not find profile');
expect(ctx.stderr).to.contain('Could not find profile "alt".');
expect(ctx.stderr).to.contain('To create the profile, run:');
expect(ctx.stderr).to.contain('twilio profiles:create --profile "alt"');
expect(ctx.stderr).to.contain('TWILIO_ACCOUNT_SID');
Expand Down

0 comments on commit e753fcd

Please sign in to comment.