@@ -37,7 +37,7 @@ function findRuntimePath() {
3737 const upPkg = readPkgUp . sync ( ) ;
3838 // case 1: we're in NR itself
3939 if ( upPkg . pkg . name === 'node-red' ) {
40- if ( semver . ltr ( upPkg . pkg . version , "<0.20.0" ) ) {
40+ if ( checkSemver ( upPkg . pkg . version , "<0.20.0" ) ) {
4141 return path . join ( path . dirname ( upPkg . path ) , upPkg . pkg . main ) ;
4242 } else {
4343 return path . join ( path . dirname ( upPkg . path ) , "packages" , "node_modules" , "node-red" ) ;
@@ -58,6 +58,14 @@ function findRuntimePath() {
5858 }
5959}
6060
61+
62+ // As we have prerelease tags in development version, they need stripping off
63+ // before semver will do a sensible comparison with a range.
64+ function checkSemver ( localVersion , testRange ) {
65+ var parts = localVersion . split ( "-" ) ;
66+ return semver . satisfies ( parts [ 0 ] , testRange ) ;
67+ }
68+
6169class NodeTestHelper extends EventEmitter {
6270 constructor ( ) {
6371 super ( ) ;
@@ -79,8 +87,7 @@ class NodeTestHelper extends EventEmitter {
7987 this . _log = RED . log ;
8088 // access internal Node-RED runtime methods
8189 const prefix = path . dirname ( requirePath ) ;
82-
83- if ( semver . ltr ( RED . version ( ) , "<0.20.0" ) ) {
90+ if ( checkSemver ( RED . version ( ) , "<0.20.0" ) ) {
8491 this . _context = require ( path . join ( prefix , 'runtime' , 'nodes' , 'context' ) ) ;
8592 this . _comms = require ( path . join ( prefix , 'api' , 'editor' , 'comms' ) ) ;
8693 this . credentials = require ( path . join ( prefix , 'runtime' , 'nodes' , 'credentials' ) ) ;
@@ -99,6 +106,7 @@ class NodeTestHelper extends EventEmitter {
99106 this . _NodePrototype = require ( path . join ( prefix , '@node-red/runtime/lib/nodes/Node' ) ) . prototype ;
100107 }
101108 } catch ( ignored ) {
109+ console . log ( ignored ) ;
102110 // ignore, assume init will be called again by a test script supplying the runtime path
103111 }
104112 }
0 commit comments