Socket
Socket
Sign inDemoInstall

nlf

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlf - npm Package Compare versions

Comparing version 1.3.2 to 1.4.0

.coverdata/.cover_5683367964811623/_Users_ian_Personal_nlf_lib_file-source.js

4

bin/nlf-cli.js

@@ -27,2 +27,3 @@ #!/usr/bin/env node

.option('-d, --no-dev', 'exclude development dependencies')
.option('-s, --summary <mode>', 'summary (not available in csv format): off | simple (default) | detail', /^(off|simple|detail)$/i, 'simple')
.option('-c, --csv', 'output in csv format')

@@ -34,2 +35,3 @@ .option('-r, --reach [num]', 'package depth (reach)', parseInt, Infinity)

options.depth = program.reach;
options.summaryMode = program.summary;

@@ -51,3 +53,3 @@ // select which formatter

if (data && data.length > 0) {
format.render(data, function (err, output) {
format.render(data, options, function (err, output) {
if (err) {

@@ -54,0 +56,0 @@ console.error(err);

@@ -0,1 +1,11 @@

1.4.0 (January 16, 2016)
====================
* Add support for reporting modules grouped by license
1.3.3 (July 14, 2015)
====================
* Ignore files that happen to be in node_module or bower_component folders
1.3.2 (July 12, 2015)

@@ -2,0 +12,0 @@ ====================

@@ -39,5 +39,6 @@ /**

* @param {Array} licenseData An array of module licence data
* @param {Object} options Options
* @param {Function} callback The callback (err, output string)
*/
function render(licenseData, callback) {
function render(licenseData, options, callback) {

@@ -44,0 +45,0 @@ if (typeof callback !== 'function') {

@@ -51,16 +51,40 @@ /**

*
* @param {Array} summaryData Array of licenses found
* @param {Object} summaryData Map: license -> modules
*/
function createSummary(summaryData) {
function createSummary(summmaryData) {
return archy({
label: 'LICENSES: ' + summaryData.sort().join(', ')
label: 'LICENSES: ' + Object.keys(summmaryData).sort().join(', ')
});
}
/**
* Create an archy output of the modules group by license
*
* @param {Object} summaryData Map: license -> modules
*/
function modulesByLicenses(summaryData) {
var output = {
label: 'LICENSES:',
nodes: []
};
for (var license in summaryData) {
if (summaryData.hasOwnProperty(license)) {
output.nodes.push({
label: license,
nodes: summaryData[license]
});
}
}
return archy(output);
}
/**
* Render the license data
*
* @param {Array} licenseData An array of module licence data
* @param {Object} options Options
* @param {Function} callback The callback (err, output string)
*/
function render(licenseData, callback) {
function render(licenseData, options, callback) {

@@ -80,3 +104,3 @@ if (typeof callback !== 'function') {

var output = [];
var summary = [];
var summary = {};

@@ -90,5 +114,7 @@ // go through all the modules, adding them to

for (var index = 0; index < moduleLicenses.length; index++) {
if (summary.indexOf(moduleLicenses[index]) === -1) {
summary.push(moduleLicenses[index]);
var license = moduleLicenses[index];
if (!summary[license]) {
summary[license] = [];
}
summary[license].push(module.id);
}

@@ -98,3 +124,10 @@ });

// add the summary
output.push(createSummary(summary));
switch (options.summaryMode) {
case 'simple':
output.push(createSummary(summary));
break;
case 'detail':
output.push(modulesByLicenses(summary));
break;
}

@@ -101,0 +134,0 @@ callback(null, output.join('\n'));

@@ -38,2 +38,6 @@ /**

if (moduleData.extraneous) {
return true;
}
var dependencies = moduleData.parent.devDependencies || {},

@@ -149,5 +153,4 @@ dependencyName;

cwd: directory,
ignore: 'node_modules/'
ignore: ['**/node_modules/**', '**/bower_components/**']
}, function(err, subdirs) {
if (err) {

@@ -169,3 +172,4 @@ return callback(err);

nocase: true,
cwd: directory
cwd: directory,
ignore: ['**/node_modules/**', '**/bower_components/**']
}, callback);

@@ -385,2 +389,10 @@

function processOptionSummaryMode(options) {
options.summaryMode = options.summaryMode || 'simple';
if (typeof options.summaryMode !== 'string') {
throw new Error('options.summaryMode must be a string');
}
options.summaryMode = options.summaryMode.toLowerCase();
}
/**

@@ -411,2 +423,4 @@ * Process the options

}
processOptionSummaryMode(options);

@@ -460,6 +474,7 @@ return options;

* @param {String} output The error message
* @param {String} details The error details
*/
function log(output) {
console.error('Error in reading node_module dependencies, error was: '
+ output);
function log(output, details) {
console.error('Error in reading node_module dependencies, error was:',
output, details);
}

@@ -466,0 +481,0 @@

@@ -6,3 +6,3 @@ {

"author": "Ian Kelly <iandotkelly@gmail.com>",
"version": "1.3.2",
"version": "1.4.0",
"license": "MIT",

@@ -19,3 +19,3 @@ "bin": {

"archy": "1.0.0",
"commander": "2.8.1",
"commander": "2.9.0",
"glob-all": "3.0.1",

@@ -28,5 +28,6 @@ "read-installed": "^4.0.1"

"gulp-coveralls": "^0.1.3",
"gulp-jshint": "^1.11.2",
"gulp-jshint": "^2.0.0",
"gulp-mocha": "^2.1.3",
"should": "^7.0.2"
"should": "^8.1.1",
"jshint": "^2.9.1"
},

@@ -33,0 +34,0 @@ "engines": {

@@ -27,2 +27,3 @@ <!-- @@NLF-IGNORE@@ -->

- `depth` (Number) (Default: Infinity) - how deep to traverse packages where 0 is the current package.json only
- `summaryMode` (String: off|simple|detail) (Default: simple)

@@ -85,2 +86,29 @@

#### Summary Mode
`--summary <mode>` option, which can be set to "off", "simple" or "detail". This option controls what will be printed in summary in standard format.
* `off` turns off summary output
* `simple` shows a list of licenses used in the project, the default behavior
* `detail` shows all modules in current project and group by licenses. As example below:
```sh
LICENSES:
├─┬ BSD
│ ├── amdefine@1.0.0
│ ├── boom@0.4.2
│ ├── cryptiles@0.2.2
│ └── diff@1.4.0
├─┬ BSD-2-Clause
│ └── normalize-package-data@2.3.5
├─┬ Apache-2.0
│ ├── request@2.40.0
│ ├── spdx-correct@1.0.2
│ └── validate-npm-package-license@3.0.1
├─┬ (MIT AND CC-BY-3.0)
│ └── spdx-expression-parse@1.0.1
└─┬ MPL
└── tough-cookie@2.2.1
```
### Programmatically

@@ -87,0 +115,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc