Add license data to NPM package and documenation (#5106)

This commit is contained in:
Eric Cornelissen 2021-03-02 13:01:31 +01:00 committed by GitHub
parent 765345cc87
commit 95109ad629
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 3 deletions

View File

@ -65,8 +65,14 @@ console.log(icon);
hex: '111111',
source: 'https://simpleicons.org/',
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">...</svg>',
path: 'M12 12v-1.5c-2.484 ...'
path: 'M12 12v-1.5c-2.484 ...',
license: {
type: '...',
url: 'https://example.com/'
}
}
NOTE: the `license` entry will be `undefined` if we do not yet have license data for the icon.
*/
```
@ -89,8 +95,14 @@ console.log(icon);
hex: '111111',
source: 'https://simpleicons.org/',
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">...</svg>',
path: 'M12 12v-1.5c-2.484 ...'
path: 'M12 12v-1.5c-2.484 ...',
license: {
type: '...',
url: 'https://example.com/'
}
}
NOTE: the license may be `undefined` if there is no license data for the icon.
*/
```

View File

@ -39,13 +39,24 @@ function iconToKeyValue(icon) {
return `'${iconName}':${iconToObject(icon)}`;
}
function licenseToObject(license) {
if (license === undefined) {
return;
}
if (license.url === undefined) {
license.url = `https://spdx.org/licenses/${license.type}.html`;
}
return license;
}
function iconToObject(icon) {
return util.format(iconObjectTemplate,
escape(icon.title),
escape(icon.slug),
escape(icon.svg),
escape(icon.source),
escape(icon.hex)
escape(icon.hex),
licenseToObject(icon.license),
);
}
function minifyAndWrite(filepath, rawJavaScript) {

View File

@ -7,4 +7,5 @@
},
source: '%s',
hex: '%s',
license: %s,
}