1
0
mirror of https://github.com/badges/shields.git synced 2025-11-09 12:40:59 +03:00
Files
shields/services/pypi/pypi-license.service.js

38 lines
887 B
JavaScript

'use strict'
const { renderLicenseBadge } = require('../../lib/licenses')
const PypiBase = require('./pypi-base')
const { getLicenses } = require('./pypi-helpers')
module.exports = class PypiLicense extends PypiBase {
static get category() {
return 'license'
}
static get route() {
return this.buildRoute('pypi/l')
}
static get examples() {
return [
{
title: 'PyPI - License',
pattern: ':packageName',
namedParams: { packageName: 'Django' },
staticPreview: { label: 'license', message: 'BSD', color: 'lightgrey' },
keywords: ['python'],
},
]
}
static render({ licenses }) {
return renderLicenseBadge({ licenses })
}
async handle({ egg }) {
const packageData = await this.fetch({ egg })
const licenses = getLicenses(packageData)
return this.constructor.render({ licenses })
}
}