File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { build } from './src/cmd/build.js';
88import { deploy } from './src/cmd/deploy.js' ;
99import { init } from './src/cmd/init.js' ;
1010import { serve } from './src/cmd/serve.js' ;
11+ import { preFlightChecks } from './src/util/preFlightChecks.js' ;
1112import packageJson from './package.json' with { type : 'json' } ;
1213
1314const CLI_VERSION = packageJson . version ;
@@ -23,6 +24,9 @@ function printHeader() {
2324 return '' ;
2425}
2526
27+ program
28+ . hook ( 'preAction' , ( ) => preFlightChecks ( ) ) ;
29+
2630program
2731 . addHelpText ( 'beforeAll' , printHeader ( ) )
2832 . showHelpAfterError ( '(run "markbind --help" to list commands)' )
Original file line number Diff line number Diff line change 4545 "fs-extra" : " ^9.0.1" ,
4646 "live-server" : " 1.2.1" ,
4747 "lodash" : " ^4.17.15" ,
48+ "semver" : " ^7.7.4" ,
4849 "url-parse" : " ^1.5.10" ,
4950 "winston" : " ^3.19.0" ,
5051 "winston-daily-rotate-file" : " ^5.0.0"
5354 "@babel/core" : " ^7.29.0" ,
5455 "@babel/preset-env" : " ^7.29.0" ,
5556 "@babel/preset-typescript" : " ^7.28.5" ,
57+ "@types/semver" : " ^7.7.1" ,
5658 "@types/jest" : " ^29.4.6" ,
5759 "@types/lodash" : " ^4.17.15" ,
5860 "@types/url-parse" : " ^1.4.8" ,
Original file line number Diff line number Diff line change 1+ import * as semver from 'semver' ;
2+ import * as logger from './logger.js' ;
3+ import packageJson from '../../package.json' with { type : 'json' } ;
4+
5+ const CLI_VERSION = packageJson . version ;
6+ const REQUIRED_NODE_VERSION = '22.12.0' ;
7+
8+ function checkNode ( ) {
9+ const nodeVersion = process . version ;
10+ const version = semver . coerce ( nodeVersion ) ;
11+
12+ if ( version === null ) {
13+ logger . warn ( 'Unknown version of node detected.' ) ;
14+ return ;
15+ }
16+ if ( semver . lt ( version , REQUIRED_NODE_VERSION ) ) {
17+ logger . error (
18+ `Markbind ${ CLI_VERSION } requires node >=${ REQUIRED_NODE_VERSION } . `
19+ + 'Please update node or use an older version of Markbind!' ,
20+ ) ;
21+ process . exit ( 1 ) ;
22+ }
23+ }
24+
25+ /**
26+ * Performs pre-usage checks to ensure the application will run as expected.
27+ * This method may exit the process if checks fail.
28+ */
29+ export function preFlightChecks ( ) {
30+ checkNode ( ) ;
31+ }
You can’t perform that action at this time.
0 commit comments