@@ -3,6 +3,9 @@ const got = require('got')
33const semver = require ( 'semver' )
44const _cache = new Map ( )
55
6+ // Only print warning about future versions ones per process
7+ let futureVersionsWarningShown = false
8+
69module . exports = async function ( alias = 'lts_active' , opts = { } ) {
710 const now = opts . now || new Date ( )
811 const cache = opts . cache || _cache
@@ -81,6 +84,8 @@ async function getLatestVersionsByCodename (now, cache, mirror, ignoreFutureRele
8184 const ltsActive = { }
8285 const lts = { }
8386
87+ const futureVersions = [ ]
88+
8489 const aliases = versions . reduce ( ( obj , ver ) => {
8590 const { major, minor, patch, tag } = splitVersion ( ver . version )
8691 const versionName = major !== '0' ? `v${ major } ` : `v${ major } .${ minor } `
@@ -114,8 +119,12 @@ async function getLatestVersionsByCodename (now, cache, mirror, ignoreFutureRele
114119 }
115120
116121 // This version is from future; completely ignore it (i.e. we may have specified a `now` from the past)
117- if ( ignoreFutureReleases && now < v . releaseDate ) {
118- return obj
122+ if ( now < v . releaseDate ) {
123+ if ( ignoreFutureReleases ) {
124+ return obj
125+ } else {
126+ futureVersions . push ( v )
127+ }
119128 }
120129
121130 // All versions get added to all
@@ -178,6 +187,16 @@ async function getLatestVersionsByCodename (now, cache, mirror, ignoreFutureRele
178187 // nvm 'node'
179188 aliases . node = aliases . current
180189
190+ // Print warning about future versions
191+ if ( ! futureVersionsWarningShown && futureVersions . length ) {
192+ futureVersionsWarningShown = true
193+ process . emitWarning (
194+ `${ futureVersions . length } node versions have a releaseDate in the future and may not be ready for use. Pass ignoreFutureReleases to exclude these.` ,
195+ 'Warning' ,
196+ 'nv-future-release'
197+ )
198+ }
199+
181200 // Deprecated maintained alias
182201 let deprecationShown = false
183202 Object . defineProperty ( aliases , 'maintained' , {
0 commit comments