Add Node version guard for unsupported runtimes#319
Merged
Conversation
Split CLI into a tiny launcher (src/cli.ts) that checks for Node >= 22.13.0 before dynamically importing the full CLI (src/main.ts). Users on Node 18 now get a clear upgrade message instead of a cryptic regex parse error from string-width. Closes #232.
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
src/cli.ts) + full CLI (src/main.ts)SyntaxError: Invalid regular expression flagsfromstring-widthenginesfield to>=22.13.0to match the actual floorcpdependency)Closes #232.
Why two files?
The crash is a parse error -- Node 18 can't even load the bundle because
string-widthuses the/vregex flag (Node 20+). A runtime check in the same file won't help because the file fails to parse before any code runs. The launcher must be a separate file that Node 18 can parse.Build output
dist/cli.js-- 400-byte launcher (version check + dynamic import)dist/main.js-- 667KB bundle (the actual CLI)Test plan
node dist/cli.js --versionworksnode dist/cli.js report --format jsonproduces valid outputcpdependency).catch()for proper error handling