File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import util from 'util';
25
25
import read from 'read' ;
26
26
import os from 'os' ;
27
27
import fs from 'fs' ;
28
+ import semver from 'semver' ;
28
29
29
30
/**
30
31
* Connecting text key.
@@ -50,6 +51,7 @@ class CliRepl {
50
51
* Instantiate the new CLI Repl.
51
52
*/
52
53
constructor ( driverUri : string , driverOptions : NodeOptions , options : CliOptions ) {
54
+ this . verifyNodeVersion ( ) ;
53
55
this . options = options ;
54
56
this . mongoshDir = path . join ( os . homedir ( ) , '.mongodb/mongosh/' ) ;
55
57
this . lineByLineInput = new LineByLineInput ( process . stdin ) ;
@@ -307,6 +309,14 @@ class CliRepl {
307
309
return formatOutput ( result ) ;
308
310
} ;
309
311
312
+ verifyNodeVersion ( ) : void {
313
+ const { engines } = require ( '../package.json' ) ;
314
+ if ( ! semver . satisfies ( process . version , engines . node ) ) {
315
+ console . log ( `WARNING: mismatched node version. Minimum node version required ${ engines . node } . Currently using ${ process . version } . Exiting...\n\n` ) ;
316
+ process . exit ( 1 ) ;
317
+ }
318
+ }
319
+
310
320
/**
311
321
* The greeting for the shell.
312
322
*/
You can’t perform that action at this time.
0 commit comments