-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: 1.0.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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() | ||
|
||
|
@@ -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) | ||
} | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
|
There was a problem hiding this comment.
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