-
Notifications
You must be signed in to change notification settings - Fork 144
Add node preFlight checks to CLI #2892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||
| import * as semver from 'semver'; | ||||||||||||||||||||
| import * as logger from './logger.js'; | ||||||||||||||||||||
| import packageJson from '../../package.json' with { type: 'json' }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const CLI_VERSION = packageJson.version; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| function checkNode() { | ||||||||||||||||||||
| const nodeVersion = process.version; | ||||||||||||||||||||
| const version = nodeVersion.slice(1); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (semver.lt(version, '22.12.0')) { | ||||||||||||||||||||
| logger.error( | ||||||||||||||||||||
| `Markbind ${CLI_VERSION} requires Node >=22.12.0. ` | ||||||||||||||||||||
|
Harjun751 marked this conversation as resolved.
Outdated
|
||||||||||||||||||||
| + 'Please update Node or use an older version of MarkBind!' | ||||||||||||||||||||
| ); | ||||||||||||||||||||
| process.exit(1); | ||||||||||||||||||||
|
Comment on lines
+17
to
+21
|
||||||||||||||||||||
| logger.error( | |
| `Markbind ${CLI_VERSION} requires Node >=22.12.0. ` | |
| + 'Please update Node or use an older version of MarkBind!' | |
| ); | |
| process.exit(1); | |
| const message = `Markbind ${CLI_VERSION} requires Node >=22.12.0. ` | |
| + 'Please update Node or use an older version of MarkBind!'; | |
| logger.error(message); | |
| throw new Error(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking to leave this in. Throwing an error will print the whole stack trace to the user, it's ugly and less helpful from the user's standpoint IMO.
Instead I've added some explicit documentation through jsDoc that says calling the function may exit the process if checks fail.
Uh oh!
There was an error while loading. Please reload this page.