(dep: Dependency)
| 155 | } |
| 156 | |
| 157 | function getDependencyInformation(dep: Dependency): DependencyInfo { |
| 158 | const info: DependencyInfo = {} |
| 159 | const { license, author, maintainers, contributors, repository } = dep |
| 160 | |
| 161 | if (license) { |
| 162 | info.license = license |
| 163 | } |
| 164 | |
| 165 | const names = new Set<string>() |
| 166 | for (const person of [author, ...maintainers, ...contributors]) { |
| 167 | const name = typeof person === 'string' ? person : person?.name |
| 168 | if (name) { |
| 169 | names.add(name) |
| 170 | } |
| 171 | } |
| 172 | if (names.size > 0) { |
| 173 | info.names = Array.from(names).join(', ') |
| 174 | } |
| 175 | |
| 176 | if (repository) { |
| 177 | info.repository = normalizeGitUrl( |
| 178 | typeof repository === 'string' ? repository : repository.url, |
| 179 | ) |
| 180 | } |
| 181 | |
| 182 | return info |
| 183 | } |
| 184 | |
| 185 | function normalizeGitUrl(url: string): string { |
| 186 | url = url |
no test coverage detected