Skip to content

Commit 216b28a

Browse files
committed
feat!: removed got and replaced it with fetch
1 parent 59fd39a commit 216b28a

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
const got = require('got')
2+
// const got = require('got')
33
const semver = require('semver')
44
const _cache = new Map()
55

@@ -59,15 +59,21 @@ function resolveAlias (versions, alias) {
5959
}
6060

6161
function getSchedule (cache) {
62-
return got('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json', {
63-
cache
64-
}).json()
62+
const cached = cache.get('schedule')
63+
if (cached) {
64+
return Promise.resolve(cached)
65+
}
66+
return fetch('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json')
67+
.then((res) => res.json())
6568
}
6669

6770
function getVersions (cache, mirror) {
68-
return got(mirror.replace(/\/$/, '') + '/index.json', {
69-
cache
70-
}).json()
71+
const cached = cache.get('versions')
72+
if (cached) {
73+
return Promise.resolve(cached)
74+
}
75+
return fetch(mirror.replace(/\/$/, '') + '/index.json')
76+
.then((res) => res.json())
7177
}
7278

7379
async function getLatestVersionsByCodename (now, cache, mirror) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
"release": "npm t && standard-version && npm publish"
3535
},
3636
"dependencies": {
37-
"got": "^11.8.3",
3837
"semver": "^7.1.1",
3938
"yargs": "^16.2.0"
4039
},
4140
"devDependencies": {
41+
"@types/node": "^20.14.11",
4242
"gen-esm-wrapper": "^1.1.3",
4343
"mocha": "^10.6.0",
4444
"standard": "^17.1.0",

0 commit comments

Comments
 (0)