tiny-license.js
Create a tiny JavaScript license comment from package data
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
npm
npm install tiny-license
Bower
bower install tiny-license
Duo
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 and bower.json, and returns a string of JavaScript block comment which represents the license of the package.
It uses the follwing properties of data:
name
-
author
orauthors
-
license
orlicenses
homepage
All of them are optional.
var json = {
name: 'foo',
authors: [
'John Smith <bar@email> (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.
var json = {name: 'foo'};
tinyLicense(json); //=> '/*!\n * foo\n*/\n'
tinyLicense(json, {lastNewline: false}); //=> '/*!\n * foo\n*/'
License
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.