11'use strict'
22var semver = require ( 'semver' )
3- var earliestSupportedNode = '9.3.0'
4- var supportedNode = [
5- { ver : '6' , min : '6.0.0' } ,
6- { ver : '8' , min : '8.0.0' } ,
7- { ver : '9' , min : '9.0.0' } ,
8- { ver : '10' , min : '10.0.0' } ,
9- { ver : '11' , min : '11.0.0' } ,
10- { ver : '12' , min : '12.0.0' } ,
11- { ver : '13' , min : '13.0.0' } ,
12- { ver : '14' , min : '14.0.0' }
13- ]
14- var knownBroken = '<6.2.0 || 9.0 - 9.2'
3+ var supported = require ( '../../package.json' ) . engines . node
4+ var knownBroken = '<6.2.0 || 9 <9.3.0'
155
166var checkVersion = exports . checkVersion = function ( version ) {
177 var versionNoPrerelease = version . replace ( / - .* $ / , '' )
18- var isExplicitlySupportedNode = semver . satisfies ( versionNoPrerelease , supportedNode . map ( function ( n ) { return '^' + n . min } ) . join ( '||' ) )
198 return {
209 version : versionNoPrerelease ,
2110 broken : semver . satisfies ( versionNoPrerelease , knownBroken ) ,
22- unsupported : ! isExplicitlySupportedNode || ! semver . gte ( versionNoPrerelease , earliestSupportedNode )
11+ unsupported : ! semver . satisfies ( versionNoPrerelease , supported )
2312 }
2413}
2514
@@ -36,9 +25,8 @@ exports.checkForBrokenNode = function () {
3625 }
3726 } )
3827 var supportedMajors = supportedNode . map ( function ( n ) { return n . ver } ) . join ( ', ' )
39- console . error ( "You'll need to upgrade to a newer version in order to use this" )
40- console . error ( 'version of npm. Supported versions are ' + supportedMajors + '. You can find the' )
41- console . error ( 'latest version at https://nodejs.org/' )
28+ console . error ( "You'll need to upgrade to a newer Node.js version in order to use this" )
29+ console . error ( 'version of npm. You can find the latest version at https://nodejs.org/' )
4230 process . exit ( 1 )
4331 }
4432}
@@ -51,7 +39,6 @@ exports.checkForUnsupportedNode = function () {
5139 log . warn ( 'npm' , 'npm does not support Node.js ' + process . version )
5240 log . warn ( 'npm' , 'You should probably upgrade to a newer version of node as we' )
5341 log . warn ( 'npm' , "can't make any promises that npm will work with this version." )
54- log . warn ( 'npm' , 'Supported releases of Node.js are the latest release of ' + supportedMajors + '.' )
5542 log . warn ( 'npm' , 'You can find the latest version at https://nodejs.org/' )
5643 }
5744}
0 commit comments