Skip to content
Create a tiny JavaScript license comment from package data
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.editorconfig
.eslintrc
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
appveyor.yml
bower.json
component.json
package.json
test.js
tiny-license-cjs.js
tiny-license.js

README.md

tiny-license.js

Build Status Build status Coverage Status Dependency Status devDependency Status

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 version Bower version

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 or authors
  • license or licenses
  • 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.

Something went wrong with that request. Please try again.