From 216b28a2fd5c008ee3cce5dc5da604b8e75566ef Mon Sep 17 00:00:00 2001 From: Wes Todd Date: Tue, 16 Jul 2024 16:46:56 -0700 Subject: [PATCH] feat!: removed got and replaced it with fetch --- index.js | 20 +++++++++++++------- package.json | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index c5672bf..ad9be17 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ 'use strict' -const got = require('got') +// const got = require('got') const semver = require('semver') const _cache = new Map() @@ -59,15 +59,21 @@ function resolveAlias (versions, alias) { } function getSchedule (cache) { - return got('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json', { - cache - }).json() + const cached = cache.get('schedule') + if (cached) { + return Promise.resolve(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() + const cached = cache.get('versions') + if (cached) { + return Promise.resolve(cached) + } + return fetch(mirror.replace(/\/$/, '') + '/index.json') + .then((res) => res.json()) } async function getLatestVersionsByCodename (now, cache, mirror) { diff --git a/package.json b/package.json index 5f1fbb2..961151d 100644 --- a/package.json +++ b/package.json @@ -34,11 +34,11 @@ "release": "npm t && standard-version && npm publish" }, "dependencies": { - "got": "^11.8.3", "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.0",