fix: clear BROWSERSLIST env before generator execution (fixes #1781)#2114
Open
armorbreak001 wants to merge 2 commits intoasyncapi:masterfrom
Open
fix: clear BROWSERSLIST env before generator execution (fixes #1781)#2114armorbreak001 wants to merge 2 commits intoasyncapi:masterfrom
armorbreak001 wants to merge 2 commits intoasyncapi:masterfrom
Conversation
…i#1781) When installed via pnpm globally, the BROWSERSLIST environment variable may contain shell script content that PostCSS/Autoprefixer misinterprets as browser queries, causing: 'Unknown browser query basedir=...' This fix clears BROWSERSLIST at the CLI entry point (BaseGeneratorCommand) before ANY template/generator runs, and restores it afterwards via try/finally. This covers all templates without requiring individual changes. Advantages over generator-level fix: - Covers ALL templates automatically (not just specific ones) - Uses try/finally to guarantee restoration even on errors - Smaller diff (+15 lines in existing file vs +32 lines new file) Fixes asyncapi#1781
|
…ixes asyncapi#1781) Improved the Browserslist fix to be smarter: - Only clears BROWSERSLIST when value contains shell script patterns ( - Preserves legitimate browser query values like 'last 2 Chrome versions' - This avoids breaking users who intentionally set BROWSERSLIST for PostCSS/Autoprefixer targeting
|
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.



Description
Closes #1781
Problem
When AsyncAPI CLI is installed via pnpm globally, running
asyncapi generatewith the HTML template fails with:Root cause: pnpm sets
BROWSERSLISTto a shell script string. PostCSS/Autoprefixer (used by@asyncapi/html-template) tries to parse it as browser queries and chokes.Solution
Clear
BROWSERSLISTat the CLI entry point (BaseGeneratorCommand.generate()) before any generator/template runs. Restore it afterwards viatry/finally.Why This Approach
withCleanBrowserslistEnv()Changes
src/apps/cli/internal/base/BaseGeneratorCommand.ts: Save → clear → (generate) → restoreBROWSERSLISTTesting
pnpm add -g @asyncapi/cli && asyncapi generate ...with HTML template