https://github.com/shinnn/tiny-license.js
Create a tiny JavaScript license comment from package data
https://github.com/shinnn/tiny-license.js
Last synced: 25 days ago
JSON representation
Create a tiny JavaScript license comment from package data
- Host: GitHub
- URL: https://github.com/shinnn/tiny-license.js
- Owner: shinnn
- License: mit
- Created: 2014-11-06T09:46:42.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-17T09:08:17.000Z (over 10 years ago)
- Last Synced: 2025-05-28T10:08:22.558Z (about 1 month ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tiny-license.js
[](https://travis-ci.org/shinnn/tiny-license.js)
[](https://ci.appveyor.com/project/ShinnosukeWatanabe/tiny-license-js)
[](https://coveralls.io/r/shinnn/tiny-license.js)
[](https://david-dm.org/shinnn/tiny-license.js)
[](https://david-dm.org/shinnn/tiny-license.js#info=devDependencies)Create a tiny JavaScript license comment from package data
```javascript
var json = {
name: 'isogram',
author: 'Shinnosuke Watanabe',
homepage: 'https://github.com/shinnn/isogram'
};tinyLicense(json);
//=>
/*!
* isogram | (c) Shinnosuke Watanabe
* https://github.com/shinnn/isogram
*/
```## Installation
[](https://www.npmjs.com/package/tiny-license)
[](https://github.com/shinnn/tiny-license.js/releases)#### [npm](https://www.npmjs.com/)
```sh
npm install tiny-license
```#### [Bower](http://bower.io/)
```sh
bower install tiny-license
```#### [Duo](http://duojs.org/)
```javascript
var tinyLicense = require('shinnn/tiny-license.js');
```## API
### tinyLicense(*packageData* [, *option*])
*packageData*: `Object`
*option*: `Object`
Return: `String`It takes data of a package definition file, like [package.json](https://www.npmjs.org/doc/files/package.json.html) and [bower.json](https://github.com/bower/bower.json-spec), and returns a string of JavaScript block comment which represents the license of the package.
It uses the follwing properties of data:
* `name`
* `author` or `authors`
* `license` or `licenses`
* `homepage`All of them are optional.
```javascript
var json = {
name: 'foo',
authors: [
'John Smith (baz.com)',
{
name: 'Mary Sue',
email: 'qux@email'
}
],
license: 'CC0-1.0',
homepage: 'http://nodejs.org/'
};tinyLicense(json);
//=>
/*!
* foo | CC0-1.0 (c) John Smith, Mary Sue
* http://nodejs.org/
*/```
#### option.lastNewline
Type: `Boolean`
Default: `true`Setting this option `false` removes the last newline from the result.
```javascript
var json = {name: 'foo'};tinyLicense(json); //=> '/*!\n * foo\n*/\n'
tinyLicense(json, {lastNewline: false}); //=> '/*!\n * foo\n*/'
```## License
Copyright (c) 2014 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).