diff --git a/index.js b/index.js index 269fa43..2831d8f 100644 --- a/index.js +++ b/index.js @@ -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() @@ -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 }) { diff --git a/package.json b/package.json index 894e6d1..2dd6d88 100644 --- a/package.json +++ b/package.json @@ -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", @@ -51,6 +51,6 @@ "nv": "./bin/nv" }, "engines": { - "node": "^18 || ^20 || ^22" + "node": "^20 || ^22 || >24" } }