Repository navigation
Conversation
…xt commands (asyncapi#2311) - Fix operator precedence bug in instanceof expression across all 6 context commands - Remove unused ContextFileWrongFormatError imports - Remove unreachable (fileContent && !fileContent.current) check in current.ts - Add negative integration tests for current, list, edit, use, and remove when context file is malformed
|
There was a problem hiding this comment.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
|



Description
Across all six
config contextcommands (add,current,edit,list,remove, anduse), error handling previously checked:Because
(MissingContextFileError || ContextFileWrongFormatError)evaluates first in JavaScript andMissingContextFileError(a class constructor) is truthy, the expression always evaluates toMissingContextFileError, leavingContextFileWrongFormatErrorun-evaluated.This PR cleans up this construct and adds missing negative tests:
e instanceof (MissingContextFileError || ContextFileWrongFormatError)withe instanceof MissingContextFileErrorin all six commands (add.ts,current.ts,edit.ts,list.ts,remove.ts,use.ts).ContextFileWrongFormatErrorimports across all six commands.current.ts, removes the dead check|| (fileContent && !fileContent.current)inside thecatch (e)block wherefileContentis alwaysundefined.test/integration/context.test.tsforcurrent,list,edit,use, andremovewith a malformed context file to verify thatContextError: Context file "..." has wrong format.is cleanly emitted.Related issue(s)
Fixes #2311