Skip to content

Commit

Permalink
Fix Packument['versions'] type.
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Nov 3, 2023
1 parent bc0951b commit 863c4c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/package-managers/npm.ts
Expand Up @@ -46,7 +46,7 @@ const fetchPackument = async (
opts: fetch.Options & {
fullMetadata?: boolean
},
): Promise<any> => {
): Promise<Packument> => {
const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*'
const fullDoc = 'application/json'
const headers = {
Expand Down Expand Up @@ -337,7 +337,7 @@ export const mockViewMany =
},
version,
// overwritten below
versions: [],
versions: {},
...(isPackument(partialPackument) ? partialPackument : null),
}

Expand All @@ -354,7 +354,9 @@ export const mockViewMany =
} as Index<string>)
: ({
...packument,
versions: [packument],
versions: {
[version]: packument,
},
} as Packument),
})),
)
Expand Down
5 changes: 4 additions & 1 deletion src/types/Packument.ts
Expand Up @@ -3,6 +3,9 @@ import { Version } from './Version'

/** A pacote packument result object. */
export interface Packument {
_npmUser?: {
name: string
}
name: string
deprecated?: boolean
engines: {
Expand All @@ -12,5 +15,5 @@ export interface Packument {
// TODO: store only the time of the latest version?
time?: Index<string>
version: Version
versions: Packument[]
versions: Index<Packument>
}

0 comments on commit 863c4c3

Please sign in to comment.