Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'
const { readFile } = require('fs/promises')
const { join } = require('path')

const got = require('got')
const semver = require('semver')
const _cache = new Map()

Expand Down Expand Up @@ -81,16 +79,22 @@ function resolveAlias (versions, alias) {
}
}

function getSchedule (cache) {
return got('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json', {
cache
}).json()
async function getSchedule (cache) {
const cached = cache.get('schedule')
if (cached) {
return cached
}
return fetch('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json')
.then((res) => res.json())
}

function getVersions (cache, mirror) {
return got(mirror.replace(/\/$/, '') + '/index.json', {
cache
}).json()
async function getVersions (cache, mirror) {
const cached = cache.get('versions')
if (cached) {
return cached
}
return fetch(mirror.replace(/\/$/, '') + '/index.json')
.then((res) => res.json())
}

async function getLatestVersionsByCodename ({ now, cache, mirror, ignoreFutureReleases }) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"release": "npm t && standard-version && npm publish"
},
"dependencies": {
"got": "^11.8.6",
"semver": "^7.1.1",
"yargs": "^16.2.0"
},
"devDependencies": {
"@types/node": "^20.14.11",
"gen-esm-wrapper": "^1.1.3",
"mocha": "^10.6.0",
"standard": "^17.1.2",
Expand All @@ -51,6 +51,6 @@
"nv": "./bin/nv"
},
"engines": {
"node": "^18 || ^20 || ^22"
"node": "^20 || ^22 || >24"
}
}