From e753fcd776f35d739fac7d980df5f6bb2ff11d35 Mon Sep 17 00:00:00 2001 From: childish-sambino Date: Tue, 16 Jun 2020 12:59:54 -0500 Subject: [PATCH] fix: don't display "undefined" when no profiles exists (#92) 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 https://github.com/twilio/twilio-cli/issues/148 --- src/base-commands/twilio-client-command.js | 3 ++- test/base-commands/twilio-client-command.test.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/base-commands/twilio-client-command.js b/src/base-commands/twilio-client-command.js index bcc15df2..eb9adcb7 100644 --- a/src/base-commands/twilio-client-command.js +++ b/src/base-commands/twilio-client-command.js @@ -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); } diff --git a/test/base-commands/twilio-client-command.test.js b/test/base-commands/twilio-client-command.test.js index ea1aaca3..e68cd1f8 100644 --- a/test/base-commands/twilio-client-command.test.js +++ b/test/base-commands/twilio-client-command.test.js @@ -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'); @@ -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');