Skip to content

Commit

Permalink
fix: the license may be an object (#587)
Browse files Browse the repository at this point in the history
有些 package 的 license 是个对象,会导致 es 写入失败
#585 (comment)


![image](https://github.com/cnpm/cnpmcore/assets/13284978/4343a1e8-1fa5-4aed-950d-d5038534dad8)
  • Loading branch information
Beace authored Sep 5, 2023
1 parent 6d156a5 commit 88b6afb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/core/service/PackageSearchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class PackageSearchService extends AbstractService {
keywords: manifest.keywords || [],
versions: Object.keys(manifest.versions),
description: manifest.description,
license: manifest.license,
license: typeof manifest.license === 'object' ? manifest.license?.type : manifest.license,
maintainers: manifest.maintainers,
author: formatAuthor(manifest.author),
'dist-tags': manifest['dist-tags'],
Expand Down
7 changes: 6 additions & 1 deletion app/repository/PackageRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type PackageJSONType = CnpmcorePatchInfo & {
url?: string;
email?: string;
};
license?: string;
license?: LicenseType | string;
author?: AuthorType | string;
contributors?: ContributorType[] | string[];
maintainers?: ContributorType[] | string[];
Expand Down Expand Up @@ -131,6 +131,11 @@ export type AuthorType = {
url?: string;
};

type LicenseType = {
type: string;
url: string;
};

type ContributorType = {
name?: string;
email?: string;
Expand Down

0 comments on commit 88b6afb

Please sign in to comment.