Skip to content

Commit 7c253d8

Browse files
committed
feat!: removed got and replaced it with fetch
1 parent b6bc159 commit 7c253d8

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
'use strict'
22
const { readFile } = require('fs/promises')
33
const { join } = require('path')
4-
5-
const got = require('got')
64
const semver = require('semver')
75
const _cache = new Map()
86

@@ -81,16 +79,22 @@ function resolveAlias (versions, alias) {
8179
}
8280
}
8381

84-
function getSchedule (cache) {
85-
return got('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json', {
86-
cache
87-
}).json()
82+
async function getSchedule (cache) {
83+
const cached = cache.get('schedule')
84+
if (cached) {
85+
return cached
86+
}
87+
return fetch('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json')
88+
.then((res) => res.json())
8889
}
8990

90-
function getVersions (cache, mirror) {
91-
return got(mirror.replace(/\/$/, '') + '/index.json', {
92-
cache
93-
}).json()
91+
async function getVersions (cache, mirror) {
92+
const cached = cache.get('versions')
93+
if (cached) {
94+
return cached
95+
}
96+
return fetch(mirror.replace(/\/$/, '') + '/index.json')
97+
.then((res) => res.json())
9498
}
9599

96100
async function getLatestVersionsByCodename ({ now, cache, mirror, ignoreFutureReleases }) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
"release": "npm t && standard-version && npm publish"
3737
},
3838
"dependencies": {
39-
"got": "^11.8.6",
4039
"semver": "^7.1.1",
4140
"yargs": "^16.2.0"
4241
},
4342
"devDependencies": {
43+
"@types/node": "^20.14.11",
4444
"gen-esm-wrapper": "^1.1.3",
4545
"mocha": "^10.6.0",
4646
"standard": "^17.1.2",

0 commit comments

Comments
 (0)