Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-undefined-error-in-fail-callback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smartthings/cli": patch
---

Fix TypeError crash when running `smartthings` or `smartthings -h` without a subcommand. Yargs passes `undefined` as the error argument to the `.fail()` callback for validation failures; the `in` operator threw when the operand was `undefined`.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const buildInstance = (commands: CommandModule<object, any>[]): Argv => {
/* eslint-enable @typescript-eslint/naming-convention */
.completion('generate-completions-script', 'output completion script setup')
.fail((message, error, yargs) => {
if ('isAxiosError' in error && error.isAxiosError) {
if (error && 'isAxiosError' in error && error.isAxiosError) {
// We don't print axiosError.message here because it just duplicates the things
// we're displaying but unformatted.
const axiosError = error as AxiosError
Expand Down