fix: call standalone isLocalTemplate function instead of thisArg method in runWatchMode#2067
Closed
chengyixu wants to merge 1 commit intoasyncapi:masterfrom
Closed
Conversation
…od in runWatchMode Fixes asyncapi#2018 In runWatchMode(), the code called thisArg.isLocalTemplate() but isLocalTemplate is a standalone exported function, not a method on the command instance (thisArg). This caused a TypeError crash immediately after initial generation when using --watch. Fix: call the imported isLocalTemplate() function directly instead of thisArg.isLocalTemplate().
🦋 Changeset detectedLatest commit: c56de96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Author
|
Hi @asyncapi/cli-maintainers! All CI checks are passing for this PR. Happy to make any adjustments needed for merge. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes #2018
Root Cause
In
runWatchMode()insrc/utils/generate/watcher.ts, the code on line 198 called:However,
isLocalTemplateis a standalone exported function (line 11), not a method on the CLI command instance (thisArg). This causes an immediateTypeError: thisArg.isLocalTemplate is not a functioncrash after the initial generation completes when using--watch.Fix
Call the
isLocalTemplate()function directly (which is already in scope via the same file) instead of calling it as a method onthisArg:How to Reproduce (before fix)
After initial generation, the watcher crashes with:
Testing
The fix is a one-line change calling the existing exported function directly. No logic change — only the call site is corrected.