Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace got with fetch #38

Open
wants to merge 1 commit into
base: 1.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict'
const got = require('got')
const semver = require('semver')
const _cache = new Map()

Expand Down Expand Up @@ -59,15 +58,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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this was made an async function then you wouldn't need the promise wrapper

}
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

}
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",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was in implicit dependency on these types which was satisfied by bringing in got. Why it had it as a prod dep I don't think I understand, but removing got broke the type generation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be node 18, given engines.node, no?

"gen-esm-wrapper": "^1.1.3",
"mocha": "^10.6.0",
"standard": "^17.1.0",
Expand Down