@@ -8,9 +8,10 @@ module.exports = async function (alias = 'lts_active', opts = {}) {
88 const cache = opts . cache || _cache
99 const mirror = opts . mirror || 'https://nodejs.org/dist/'
1010 const latestOfMajorOnly = opts . latestOfMajorOnly || false
11+ const ignoreFutureReleases = opts . ignoreFutureReleases || false
1112
1213 const a = Array . isArray ( alias ) ? alias : [ alias ]
13- const versions = await getLatestVersionsByCodename ( now , cache , mirror )
14+ const versions = await getLatestVersionsByCodename ( now , cache , mirror , ignoreFutureReleases )
1415
1516 // Reduce to an object
1617 let m = a . reduce ( ( m , a ) => {
@@ -70,7 +71,7 @@ function getVersions (cache, mirror) {
7071 } ) . json ( )
7172}
7273
73- async function getLatestVersionsByCodename ( now , cache , mirror ) {
74+ async function getLatestVersionsByCodename ( now , cache , mirror , ignoreFutureReleases ) {
7475 const schedule = await getSchedule ( cache )
7576 const versions = await getVersions ( cache , mirror )
7677
@@ -112,6 +113,11 @@ async function getLatestVersionsByCodename (now, cache, mirror) {
112113 }
113114 }
114115
116+ // 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
119+ }
120+
115121 // All versions get added to all
116122 obj . all . push ( v )
117123
0 commit comments