Skip to content

Commit

Permalink
resolve: Replace request with fetch
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
thgreasi committed Jul 12, 2024
1 parent 79389be commit b3b91ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
20 changes: 7 additions & 13 deletions lib/resolve/resolvers/nodeResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
import * as memoize from 'memoizee';

import * as _ from 'lodash';
import * as request from 'request';
import * as semver from 'semver';
import { promisify } from 'util';

const getAsync = promisify(request.get);

import type { Bundle, FileInfo, Resolver } from '../resolver';
import type { ParsedPathPlus } from '../utils';
Expand All @@ -34,19 +30,17 @@ const getDeviceTypeVersions = memoize(
let nextUrl: string | undefined =
`https://hub.docker.com/v2/repositories/resin/${deviceType}-node/tags/?page_size=100`;
while (nextUrl != null) {
const res = (
await getAsync({
url: nextUrl,
json: true,
})
).body as { results: Array<{ name: string }>; next?: string };

const curr: string[] = res.results
const response = (await fetch(nextUrl).then((res) => res.json())) as {
results: Array<{ name: string }>;
next?: string;
};

const curr: string[] = response.results
.map(({ name }) => name)
.filter(versionTest);

tags.push(...curr);
nextUrl = res.next;
nextUrl = response.next;
}

return tags;
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"@types/mz": "^2.7.4",
"@types/node": "^18.19.39",
"@types/proxyquire": "^1.3.28",
"@types/request": "^2.48.4",
"@types/semver": "^7.3.5",
"@types/tar-stream": "^2.2.0",
"chai": "^4.3.4",
Expand Down Expand Up @@ -84,7 +83,6 @@
"mz": "^2.7.0",
"p-map": "^4.0.0",
"pinejs-client-core": "^6.13.0",
"request": "^2.88.2",
"semver": "^7.3.5",
"stream-to-promise": "^3.0.0",
"tar-stream": "^3.1.6",
Expand Down

0 comments on commit b3b91ca

Please sign in to comment.