Skip to content

Commit

Permalink
adding npm registry client tests, small modification to npm client
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelynJefferson committed Jul 12, 2024
1 parent 9eb01a9 commit a82f35c
Show file tree
Hide file tree
Showing 2 changed files with 456 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/registry/NPMRegistryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ export class NPMRegistryClient implements RegistryClient {

async download(name: string, version: string): Promise<Readable> {
// Get the manifest information about the package from the registry
const manifestRes = await axiosGet(`${this.endpoint}/${name}`);
// Find the NPM tarball location in the manifest
let url = manifestRes.data?.versions?.[version]?.dist?.tarball;
let url;
try {
const manifestRes = await axiosGet(`${this.endpoint}/${name}`);
// Find the NPM tarball location in the manifest
url = manifestRes.data?.versions?.[version]?.dist?.tarball;
} catch {
// Do nothing. Undefined url handled below.
}
// If tarball URL is not found, fallback to standard NPM approach per
// https://docs.fire.ly/projects/Simplifier/features/api.html#package-server-api
if (!url) {
Expand Down
Loading

0 comments on commit a82f35c

Please sign in to comment.