GithubHelp home page GithubHelp logo

nlf's Introduction

Node License Finder (nlf) Build Status Dependency Status

nlf is a utility for attempting to identify the licenses of modules in a node.js project.

It looks for license information in package.json, readme and license files in the project. Please note, in many cases the utility is looking for standard strings in these files, such as MIT, BSD, Apache, GPL etc - this is not error free, so if you have any concerns at all about the accuracy of the results, you will need to perform a detailed manual review of the project and its dependencies, reading all terms of any included or referenced license.

Use

nlf can be used programmatically, or from the command line.

Options

  • directory (String) - where to look
  • production (Boolean) (Default:false) - only traverse dependencies, no dev-dependencies
  • depth (Number) (Default: Infinity) - how deep to traverse packages where 0 is the current package.json only

CLI

To install:

$ npm install -g nlf

To use:

$ cd my-module
$ nlf

Example output:

[email protected] [license(s): MIT]
└── readme files: MIT

[email protected] [license(s): BSD]
└── license files: BSD

[email protected] [license(s): BSD]
├── package.json:  BSD
└── license files: BSD

[email protected] [license(s): MIT/X11]
└── package.json:  MIT/X11

[email protected] [license(s): BSD]
├── package.json:  BSD
└── license files: BSD

[email protected] [license(s): MIT]
└── readme files: MIT

For output in CSV format use the -c (or --csv) switch:

$ cd my-module
$ nlf -c

To exclude development dependencies and only analyze dependencies for production:

$ cd my-module
$ nlf -d

Programmatically

var nlf = require('nlf');

nlf.find({ directory: '/User/me/my-project' }, function (err, data) {
	// do something with the response object.
	console.log(JSON.stringify(data));
});

// to only include production dependencies
nlf.find({
	directory: '/User/me/my-project',
	production: true
}, function (err, data) {
	// do something with the response object.
	console.log(JSON.stringify(data));
});

The data returned from find() is an array of modules, each of which is represented by an object as the following example:

{
  "id": "[email protected]",
  "name": "example",
  "version": "0.2.9",
  "repository": "http:\/\/github.com\/iandotkelly\/example",
  "directory": "\/Users\/ian\/example",
  "licenseSources": {
    "package": {
      "sources": [
        {
          "license": "MIT",
          "url": "http://opensource.org/MIT"
        }
      ]
    },
    "license": {
      "sources": [
        {
          "filePath": "\/Users\/ian\/Personal\/example\/LICENSE",
          "text": "the text of the license file",
          "name": function() { // function that returns the name of the license if known }
        }
      ]
    },
    "readme": {
      "sources": [
        {
          "filePath": "\/Users\/ian\/Personal\/example\/readme.md",
          "text": "text of the readme"
          "name": function() { // function that returns the name of the license if known }
        }
      ]
    }
  }
}

Each

Tests

To run the npm unit tests, install development dependencies and run tests with 'npm test' or 'make'.

$ cd nlf
$ npm install
$ npm test

If you contribute to the project, tests are written in mocha, using should.js or the node.js assert module.

License

The MIT License (MIT)

Copyright (c) 2013 Ian Kelly

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nlf's People

Contributors

iandotkelly avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.