Skip to content

Commit

Permalink
Add option to only show unknown licenses
Browse files Browse the repository at this point in the history
Remove unused references
  • Loading branch information
Philipp Tusch committed Aug 31, 2015
1 parent 2d94a19 commit c287959
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Options
-------

* `--unknown` report guessed licenses as unknown licenses.
* `--onlyunknown` only list packages with unknown or guessed licenses.
* `--json` output in json format.
* `--csv` output in csv format.
* `--out [filepath]` write the data to a specific file.
Expand Down
1 change: 1 addition & 0 deletions lib/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var nopt = require('nopt'),
markdown: Boolean,
out: require('path'),
unknown: Boolean,
onlyunknown: Boolean,
version: Boolean,
color: Boolean,
start: String,
Expand Down
17 changes: 16 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var flatten = function(options) {
data = options.data,
key = json.name + '@' + json.version,
colorize = options.color,
unknown = options.unknown,
licenseData, files = [], licenseFile;

if (colorize) {
Expand Down Expand Up @@ -48,6 +49,10 @@ var flatten = function(options) {
}
}

if (unknown) {
moduleInfo.dependencyPath = json.path;
}

licenseData = json.license || json.licenses || undefined;
if (licenseData) {
if (Array.isArray(licenseData) && licenseData.length > 0) {
Expand Down Expand Up @@ -106,6 +111,7 @@ var flatten = function(options) {
deps: childDependency,
data: data,
color: colorize,
unknown: unknown,
filter: options.filter
});
});
Expand All @@ -120,6 +126,7 @@ exports.init = function(options, callback) {
deps: json,
data: {},
color: options.color,
unknown: options.unknown,
filter: options.filter
}),
colorize = options.color,
Expand All @@ -137,7 +144,15 @@ exports.init = function(options, callback) {
}
}
if (data[item]) {
sorted[item] = data[item];
if (options.onlyunknown) {
if (data[item].licenses && data[item].licenses !== UNKNOWN) {
if (data[item].licenses.indexOf('*') > -1) {
sorted[item] = data[item];
}
}
} else {
sorted[item] = data[item];
}
}
});
callback(sorted);
Expand Down

0 comments on commit c287959

Please sign in to comment.