Skip to content

Commit

Permalink
feat!: removed got and replaced it with fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleytodd committed Jul 16, 2024
1 parent 59fd39a commit 216b28a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
const got = require('got')
// const got = require('got')
const semver = require('semver')
const _cache = new Map()

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 216b28a

Please sign in to comment.