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.1.0 to 1.2.0

7

history.md
1.2.0 (Mar 29, 2015)
====================
* Optimize globbing of files to siginificantly improve performance
* Sort output data alphabetically
* Bump dependencies
1.1.0

@@ -3,0 +10,0 @@ =================

506

lib-cov/nlf.js

@@ -7,129 +7,143 @@ /* automatically generated by JSCoverage - do not edit */

_$jscoverage['nlf.js'][13] = 0;
_$jscoverage['nlf.js'][32] = 0;
_$jscoverage['nlf.js'][31] = 0;
_$jscoverage['nlf.js'][34] = 0;
_$jscoverage['nlf.js'][35] = 0;
_$jscoverage['nlf.js'][36] = 0;
_$jscoverage['nlf.js'][39] = 0;
_$jscoverage['nlf.js'][38] = 0;
_$jscoverage['nlf.js'][43] = 0;
_$jscoverage['nlf.js'][44] = 0;
_$jscoverage['nlf.js'][45] = 0;
_$jscoverage['nlf.js'][46] = 0;
_$jscoverage['nlf.js'][47] = 0;
_$jscoverage['nlf.js'][52] = 0;
_$jscoverage['nlf.js'][63] = 0;
_$jscoverage['nlf.js'][66] = 0;
_$jscoverage['nlf.js'][75] = 0;
_$jscoverage['nlf.js'][51] = 0;
_$jscoverage['nlf.js'][62] = 0;
_$jscoverage['nlf.js'][65] = 0;
_$jscoverage['nlf.js'][74] = 0;
_$jscoverage['nlf.js'][78] = 0;
_$jscoverage['nlf.js'][79] = 0;
_$jscoverage['nlf.js'][80] = 0;
_$jscoverage['nlf.js'][85] = 0;
_$jscoverage['nlf.js'][88] = 0;
_$jscoverage['nlf.js'][84] = 0;
_$jscoverage['nlf.js'][87] = 0;
_$jscoverage['nlf.js'][90] = 0;
_$jscoverage['nlf.js'][91] = 0;
_$jscoverage['nlf.js'][92] = 0;
_$jscoverage['nlf.js'][94] = 0;
_$jscoverage['nlf.js'][93] = 0;
_$jscoverage['nlf.js'][95] = 0;
_$jscoverage['nlf.js'][96] = 0;
_$jscoverage['nlf.js'][97] = 0;
_$jscoverage['nlf.js'][101] = 0;
_$jscoverage['nlf.js'][104] = 0;
_$jscoverage['nlf.js'][100] = 0;
_$jscoverage['nlf.js'][103] = 0;
_$jscoverage['nlf.js'][106] = 0;
_$jscoverage['nlf.js'][107] = 0;
_$jscoverage['nlf.js'][108] = 0;
_$jscoverage['nlf.js'][109] = 0;
_$jscoverage['nlf.js'][112] = 0;
_$jscoverage['nlf.js'][117] = 0;
_$jscoverage['nlf.js'][119] = 0;
_$jscoverage['nlf.js'][111] = 0;
_$jscoverage['nlf.js'][116] = 0;
_$jscoverage['nlf.js'][118] = 0;
_$jscoverage['nlf.js'][124] = 0;
_$jscoverage['nlf.js'][125] = 0;
_$jscoverage['nlf.js'][126] = 0;
_$jscoverage['nlf.js'][141] = 0;
_$jscoverage['nlf.js'][143] = 0;
_$jscoverage['nlf.js'][144] = 0;
_$jscoverage['nlf.js'][147] = 0;
_$jscoverage['nlf.js'][148] = 0;
_$jscoverage['nlf.js'][146] = 0;
_$jscoverage['nlf.js'][151] = 0;
_$jscoverage['nlf.js'][152] = 0;
_$jscoverage['nlf.js'][154] = 0;
_$jscoverage['nlf.js'][155] = 0;
_$jscoverage['nlf.js'][156] = 0;
_$jscoverage['nlf.js'][157] = 0;
_$jscoverage['nlf.js'][158] = 0;
_$jscoverage['nlf.js'][162] = 0;
_$jscoverage['nlf.js'][163] = 0;
_$jscoverage['nlf.js'][166] = 0;
_$jscoverage['nlf.js'][167] = 0;
_$jscoverage['nlf.js'][170] = 0;
_$jscoverage['nlf.js'][172] = 0;
_$jscoverage['nlf.js'][173] = 0;
_$jscoverage['nlf.js'][177] = 0;
_$jscoverage['nlf.js'][189] = 0;
_$jscoverage['nlf.js'][192] = 0;
_$jscoverage['nlf.js'][165] = 0;
_$jscoverage['nlf.js'][180] = 0;
_$jscoverage['nlf.js'][182] = 0;
_$jscoverage['nlf.js'][183] = 0;
_$jscoverage['nlf.js'][186] = 0;
_$jscoverage['nlf.js'][187] = 0;
_$jscoverage['nlf.js'][191] = 0;
_$jscoverage['nlf.js'][193] = 0;
_$jscoverage['nlf.js'][196] = 0;
_$jscoverage['nlf.js'][203] = 0;
_$jscoverage['nlf.js'][194] = 0;
_$jscoverage['nlf.js'][197] = 0;
_$jscoverage['nlf.js'][201] = 0;
_$jscoverage['nlf.js'][202] = 0;
_$jscoverage['nlf.js'][204] = 0;
_$jscoverage['nlf.js'][205] = 0;
_$jscoverage['nlf.js'][208] = 0;
_$jscoverage['nlf.js'][209] = 0;
_$jscoverage['nlf.js'][210] = 0;
_$jscoverage['nlf.js'][215] = 0;
_$jscoverage['nlf.js'][216] = 0;
_$jscoverage['nlf.js'][217] = 0;
_$jscoverage['nlf.js'][219] = 0;
_$jscoverage['nlf.js'][229] = 0;
_$jscoverage['nlf.js'][231] = 0;
_$jscoverage['nlf.js'][206] = 0;
_$jscoverage['nlf.js'][207] = 0;
_$jscoverage['nlf.js'][211] = 0;
_$jscoverage['nlf.js'][223] = 0;
_$jscoverage['nlf.js'][226] = 0;
_$jscoverage['nlf.js'][227] = 0;
_$jscoverage['nlf.js'][230] = 0;
_$jscoverage['nlf.js'][237] = 0;
_$jscoverage['nlf.js'][240] = 0;
_$jscoverage['nlf.js'][241] = 0;
_$jscoverage['nlf.js'][238] = 0;
_$jscoverage['nlf.js'][239] = 0;
_$jscoverage['nlf.js'][242] = 0;
_$jscoverage['nlf.js'][243] = 0;
_$jscoverage['nlf.js'][244] = 0;
_$jscoverage['nlf.js'][246] = 0;
_$jscoverage['nlf.js'][247] = 0;
_$jscoverage['nlf.js'][249] = 0;
_$jscoverage['nlf.js'][250] = 0;
_$jscoverage['nlf.js'][251] = 0;
_$jscoverage['nlf.js'][254] = 0;
_$jscoverage['nlf.js'][255] = 0;
_$jscoverage['nlf.js'][258] = 0;
_$jscoverage['nlf.js'][259] = 0;
_$jscoverage['nlf.js'][261] = 0;
_$jscoverage['nlf.js'][262] = 0;
_$jscoverage['nlf.js'][267] = 0;
_$jscoverage['nlf.js'][268] = 0;
_$jscoverage['nlf.js'][272] = 0;
_$jscoverage['nlf.js'][273] = 0;
_$jscoverage['nlf.js'][253] = 0;
_$jscoverage['nlf.js'][263] = 0;
_$jscoverage['nlf.js'][265] = 0;
_$jscoverage['nlf.js'][271] = 0;
_$jscoverage['nlf.js'][274] = 0;
_$jscoverage['nlf.js'][275] = 0;
_$jscoverage['nlf.js'][278] = 0;
_$jscoverage['nlf.js'][280] = 0;
_$jscoverage['nlf.js'][281] = 0;
_$jscoverage['nlf.js'][285] = 0;
_$jscoverage['nlf.js'][288] = 0;
_$jscoverage['nlf.js'][289] = 0;
_$jscoverage['nlf.js'][292] = 0;
_$jscoverage['nlf.js'][293] = 0;
_$jscoverage['nlf.js'][295] = 0;
_$jscoverage['nlf.js'][298] = 0;
_$jscoverage['nlf.js'][299] = 0;
_$jscoverage['nlf.js'][300] = 0;
_$jscoverage['nlf.js'][304] = 0;
_$jscoverage['nlf.js'][313] = 0;
_$jscoverage['nlf.js'][315] = 0;
_$jscoverage['nlf.js'][317] = 0;
_$jscoverage['nlf.js'][318] = 0;
_$jscoverage['nlf.js'][321] = 0;
_$jscoverage['nlf.js'][322] = 0;
_$jscoverage['nlf.js'][324] = 0;
_$jscoverage['nlf.js'][325] = 0;
_$jscoverage['nlf.js'][328] = 0;
_$jscoverage['nlf.js'][296] = 0;
_$jscoverage['nlf.js'][301] = 0;
_$jscoverage['nlf.js'][302] = 0;
_$jscoverage['nlf.js'][306] = 0;
_$jscoverage['nlf.js'][307] = 0;
_$jscoverage['nlf.js'][308] = 0;
_$jscoverage['nlf.js'][314] = 0;
_$jscoverage['nlf.js'][327] = 0;
_$jscoverage['nlf.js'][329] = 0;
_$jscoverage['nlf.js'][332] = 0;
_$jscoverage['nlf.js'][342] = 0;
_$jscoverage['nlf.js'][333] = 0;
_$jscoverage['nlf.js'][334] = 0;
_$jscoverage['nlf.js'][339] = 0;
_$jscoverage['nlf.js'][340] = 0;
_$jscoverage['nlf.js'][341] = 0;
_$jscoverage['nlf.js'][343] = 0;
_$jscoverage['nlf.js'][344] = 0;
_$jscoverage['nlf.js'][345] = 0;
_$jscoverage['nlf.js'][346] = 0;
_$jscoverage['nlf.js'][348] = 0;
_$jscoverage['nlf.js'][349] = 0;
_$jscoverage['nlf.js'][351] = 0;
_$jscoverage['nlf.js'][361] = 0;
_$jscoverage['nlf.js'][364] = 0;
_$jscoverage['nlf.js'][365] = 0;
_$jscoverage['nlf.js'][358] = 0;
_$jscoverage['nlf.js'][360] = 0;
_$jscoverage['nlf.js'][362] = 0;
_$jscoverage['nlf.js'][363] = 0;
_$jscoverage['nlf.js'][366] = 0;
_$jscoverage['nlf.js'][369] = 0;
_$jscoverage['nlf.js'][367] = 0;
_$jscoverage['nlf.js'][368] = 0;
_$jscoverage['nlf.js'][370] = 0;
_$jscoverage['nlf.js'][372] = 0;
_$jscoverage['nlf.js'][380] = 0;
_$jscoverage['nlf.js'][381] = 0;
_$jscoverage['nlf.js'][385] = 0;
_$jscoverage['nlf.js'][386] = 0;
_$jscoverage['nlf.js'][371] = 0;
_$jscoverage['nlf.js'][374] = 0;
_$jscoverage['nlf.js'][375] = 0;
_$jscoverage['nlf.js'][378] = 0;
_$jscoverage['nlf.js'][388] = 0;
_$jscoverage['nlf.js'][390] = 0;
_$jscoverage['nlf.js'][391] = 0;
_$jscoverage['nlf.js'][392] = 0;
_$jscoverage['nlf.js'][393] = 0;
_$jscoverage['nlf.js'][394] = 0;
_$jscoverage['nlf.js'][398] = 0;
_$jscoverage['nlf.js'][400] = 0;
_$jscoverage['nlf.js'][401] = 0;
_$jscoverage['nlf.js'][405] = 0;
_$jscoverage['nlf.js'][395] = 0;
_$jscoverage['nlf.js'][397] = 0;
_$jscoverage['nlf.js'][407] = 0;
_$jscoverage['nlf.js'][410] = 0;
_$jscoverage['nlf.js'][411] = 0;
_$jscoverage['nlf.js'][412] = 0;
_$jscoverage['nlf.js'][415] = 0;
_$jscoverage['nlf.js'][416] = 0;
_$jscoverage['nlf.js'][418] = 0;
_$jscoverage['nlf.js'][426] = 0;
_$jscoverage['nlf.js'][427] = 0;
_$jscoverage['nlf.js'][431] = 0;
_$jscoverage['nlf.js'][432] = 0;
_$jscoverage['nlf.js'][436] = 0;
_$jscoverage['nlf.js'][441] = 0;
_$jscoverage['nlf.js'][442] = 0;
_$jscoverage['nlf.js'][443] = 0;
_$jscoverage['nlf.js'][447] = 0;
_$jscoverage['nlf.js'][449] = 0;
_$jscoverage['nlf.js'][450] = 0;
_$jscoverage['nlf.js'][454] = 0;
_$jscoverage['nlf.js'][459] = 0;
}

@@ -139,19 +153,19 @@ _$jscoverage['nlf.js'][11]++;

_$jscoverage['nlf.js'][13]++;
var readInstalled = require("read-installed"), Module = require("./module"), path = require("path"), fs = require("fs"), glob = require("glob"), FileSource = require("./file-source"), PackageSource = require("./package-source"), csvFormatter = require("./formatters/csv"), standardFormatter = require("./formatters/standard"), LicenseCollection = require("./license-collection"), licenseFind = require("./license-find"), matchNodeModules = /node_modules\//;
_$jscoverage['nlf.js'][32]++;
var readInstalled = require("read-installed"), Module = require("./module"), path = require("path"), fs = require("fs"), glob = require("glob-all"), FileSource = require("./file-source"), PackageSource = require("./package-source"), csvFormatter = require("./formatters/csv"), standardFormatter = require("./formatters/standard"), LicenseCollection = require("./license-collection"), licenseFind = require("./license-find");
_$jscoverage['nlf.js'][31]++;
function isDevDependency(moduleData) {
_$jscoverage['nlf.js'][35]++;
_$jscoverage['nlf.js'][34]++;
if (moduleData.parent === undefined) {
_$jscoverage['nlf.js'][36]++;
_$jscoverage['nlf.js'][35]++;
return false;
}
_$jscoverage['nlf.js'][39]++;
_$jscoverage['nlf.js'][38]++;
var dependencies = moduleData.parent.devDependencies || {}, dependencyName;
_$jscoverage['nlf.js'][44]++;
_$jscoverage['nlf.js'][43]++;
for (dependencyName in dependencies) {
_$jscoverage['nlf.js'][45]++;
_$jscoverage['nlf.js'][44]++;
if (dependencies.hasOwnProperty(dependencyName)) {
_$jscoverage['nlf.js'][46]++;
_$jscoverage['nlf.js'][45]++;
if (dependencyName === moduleData.name) {
_$jscoverage['nlf.js'][47]++;
_$jscoverage['nlf.js'][46]++;
return true;

@@ -161,48 +175,48 @@ }

}
_$jscoverage['nlf.js'][52]++;
_$jscoverage['nlf.js'][51]++;
return false;
}
_$jscoverage['nlf.js'][63]++;
_$jscoverage['nlf.js'][62]++;
function parseInstalled(data, options, callback) {
_$jscoverage['nlf.js'][66]++;
_$jscoverage['nlf.js'][65]++;
var count = 0;
_$jscoverage['nlf.js'][75]++;
_$jscoverage['nlf.js'][74]++;
(function parseModuleData(moduleData, output) {
_$jscoverage['nlf.js'][79]++;
_$jscoverage['nlf.js'][78]++;
if (options.production && isDevDependency(moduleData)) {
_$jscoverage['nlf.js'][80]++;
_$jscoverage['nlf.js'][79]++;
return;
}
_$jscoverage['nlf.js'][85]++;
_$jscoverage['nlf.js'][84]++;
if (! output.hasOwnProperty(moduleData._id)) {
_$jscoverage['nlf.js'][88]++;
_$jscoverage['nlf.js'][87]++;
output[moduleData._id] = null;
_$jscoverage['nlf.js'][90]++;
count++;
_$jscoverage['nlf.js'][91]++;
count++;
_$jscoverage['nlf.js'][92]++;
createModule(moduleData, (function (err, module) {
_$jscoverage['nlf.js'][94]++;
_$jscoverage['nlf.js'][93]++;
count--;
_$jscoverage['nlf.js'][96]++;
_$jscoverage['nlf.js'][95]++;
if (err) {
_$jscoverage['nlf.js'][97]++;
_$jscoverage['nlf.js'][96]++;
return callback(err);
}
_$jscoverage['nlf.js'][101]++;
_$jscoverage['nlf.js'][100]++;
output[moduleData._id] = module;
_$jscoverage['nlf.js'][104]++;
_$jscoverage['nlf.js'][103]++;
var dependencies = moduleData.dependencies || {}, name;
_$jscoverage['nlf.js'][107]++;
_$jscoverage['nlf.js'][106]++;
for (name in dependencies) {
_$jscoverage['nlf.js'][108]++;
_$jscoverage['nlf.js'][107]++;
if (dependencies.hasOwnProperty(name)) {
_$jscoverage['nlf.js'][109]++;
_$jscoverage['nlf.js'][108]++;
if (typeof dependencies[name] === "object") {
_$jscoverage['nlf.js'][112]++;
_$jscoverage['nlf.js'][111]++;
parseModuleData(dependencies[name], output);
}
else {
_$jscoverage['nlf.js'][117]++;
_$jscoverage['nlf.js'][116]++;
console.warn("Warning: dependency \"" + name + "\" probably not installed.");
_$jscoverage['nlf.js'][119]++;
_$jscoverage['nlf.js'][118]++;
console.warn("please install dependencies from npm before running nlf");

@@ -212,5 +226,5 @@ }

}
_$jscoverage['nlf.js'][125]++;
_$jscoverage['nlf.js'][124]++;
if (count === 0) {
_$jscoverage['nlf.js'][126]++;
_$jscoverage['nlf.js'][125]++;
callback(null, output);

@@ -222,126 +236,143 @@ }

}
_$jscoverage['nlf.js'][141]++;
_$jscoverage['nlf.js'][143]++;
function globIgnoringModules(directory, filePattern, callback) {
_$jscoverage['nlf.js'][146]++;
glob("*/", {cwd: directory, ignore: "node_modules/"}, (function (err, subdirs) {
_$jscoverage['nlf.js'][151]++;
if (err) {
_$jscoverage['nlf.js'][152]++;
return callback(err);
}
_$jscoverage['nlf.js'][156]++;
var globpatterns = [];
_$jscoverage['nlf.js'][157]++;
for (var index = 0; index < subdirs.length; index++) {
_$jscoverage['nlf.js'][158]++;
globpatterns.push(subdirs[index] + "**/" + filePattern);
}
_$jscoverage['nlf.js'][162]++;
globpatterns.push(filePattern);
_$jscoverage['nlf.js'][165]++;
glob(globpatterns, {nocase: true, cwd: directory}, callback);
}));
}
_$jscoverage['nlf.js'][180]++;
function findPotentialLicenseFiles(directory, pattern, callback) {
_$jscoverage['nlf.js'][143]++;
_$jscoverage['nlf.js'][182]++;
if (typeof pattern !== "string") {
_$jscoverage['nlf.js'][144]++;
_$jscoverage['nlf.js'][183]++;
return callback(new Error("pattern must be a string"));
}
_$jscoverage['nlf.js'][147]++;
_$jscoverage['nlf.js'][186]++;
if (typeof directory !== "string") {
_$jscoverage['nlf.js'][148]++;
_$jscoverage['nlf.js'][187]++;
return callback(new Error("directory must be a string"));
}
_$jscoverage['nlf.js'][152]++;
glob(pattern, {nocase: true, cwd: directory}, (function (err, files) {
_$jscoverage['nlf.js'][154]++;
_$jscoverage['nlf.js'][191]++;
globIgnoringModules(directory, pattern, (function (err, files) {
_$jscoverage['nlf.js'][193]++;
if (err) {
_$jscoverage['nlf.js'][155]++;
_$jscoverage['nlf.js'][194]++;
return callback(err);
}
_$jscoverage['nlf.js'][158]++;
_$jscoverage['nlf.js'][197]++;
var fileIndex, matchedFile, found = [];
_$jscoverage['nlf.js'][162]++;
_$jscoverage['nlf.js'][201]++;
for (fileIndex = files.length - 1; fileIndex >= 0; fileIndex--) {
_$jscoverage['nlf.js'][163]++;
_$jscoverage['nlf.js'][202]++;
matchedFile = files[fileIndex];
_$jscoverage['nlf.js'][166]++;
if (matchNodeModules.test(matchedFile)) {
_$jscoverage['nlf.js'][167]++;
continue;
}
_$jscoverage['nlf.js'][170]++;
_$jscoverage['nlf.js'][204]++;
var filePath = path.join(directory, matchedFile);
_$jscoverage['nlf.js'][172]++;
_$jscoverage['nlf.js'][206]++;
if (fs.statSync(filePath).isFile()) {
_$jscoverage['nlf.js'][173]++;
_$jscoverage['nlf.js'][207]++;
found.push(filePath);
}
}
_$jscoverage['nlf.js'][177]++;
_$jscoverage['nlf.js'][211]++;
callback(null, found);
}));
}
_$jscoverage['nlf.js'][189]++;
_$jscoverage['nlf.js'][223]++;
function addFiles(filePaths, collection, callback) {
_$jscoverage['nlf.js'][192]++;
_$jscoverage['nlf.js'][226]++;
if (! filePaths || filePaths.length === 0) {
_$jscoverage['nlf.js'][193]++;
_$jscoverage['nlf.js'][227]++;
return callback(null);
}
_$jscoverage['nlf.js'][196]++;
_$jscoverage['nlf.js'][230]++;
var fileIndex, pending = filePaths.length, source;
_$jscoverage['nlf.js'][203]++;
_$jscoverage['nlf.js'][237]++;
function checkDone(err) {
_$jscoverage['nlf.js'][204]++;
_$jscoverage['nlf.js'][238]++;
if (err) {
_$jscoverage['nlf.js'][205]++;
_$jscoverage['nlf.js'][239]++;
callback(err);
}
_$jscoverage['nlf.js'][208]++;
_$jscoverage['nlf.js'][242]++;
pending--;
_$jscoverage['nlf.js'][209]++;
_$jscoverage['nlf.js'][243]++;
if (! pending) {
_$jscoverage['nlf.js'][210]++;
_$jscoverage['nlf.js'][244]++;
callback(null);
}
}
_$jscoverage['nlf.js'][215]++;
_$jscoverage['nlf.js'][249]++;
for (fileIndex = 0; fileIndex < filePaths.length; fileIndex++) {
_$jscoverage['nlf.js'][216]++;
_$jscoverage['nlf.js'][250]++;
source = new FileSource(filePaths[fileIndex]);
_$jscoverage['nlf.js'][217]++;
_$jscoverage['nlf.js'][251]++;
collection.add(source);
_$jscoverage['nlf.js'][219]++;
_$jscoverage['nlf.js'][253]++;
source.read(checkDone);
}
}
_$jscoverage['nlf.js'][229]++;
_$jscoverage['nlf.js'][263]++;
function createModule(moduleData, callback) {
_$jscoverage['nlf.js'][231]++;
_$jscoverage['nlf.js'][265]++;
var repository = (moduleData.repository || {}).url || "(none)", directory = moduleData.path, module = new Module(moduleData._id, moduleData.name, moduleData.version, directory, repository);
_$jscoverage['nlf.js'][237]++;
findPotentialLicenseFiles(directory, "**/*license*", (function (err, licenseFiles) {
_$jscoverage['nlf.js'][240]++;
_$jscoverage['nlf.js'][271]++;
findPotentialLicenseFiles(directory, "*license*", (function (err, licenseFiles) {
_$jscoverage['nlf.js'][274]++;
if (err) {
_$jscoverage['nlf.js'][241]++;
_$jscoverage['nlf.js'][275]++;
return callback(err);
}
_$jscoverage['nlf.js'][244]++;
_$jscoverage['nlf.js'][278]++;
addFiles(licenseFiles, module.licenseSources.license, (function (err) {
_$jscoverage['nlf.js'][246]++;
_$jscoverage['nlf.js'][280]++;
if (err) {
_$jscoverage['nlf.js'][247]++;
_$jscoverage['nlf.js'][281]++;
return callback(err);
}
_$jscoverage['nlf.js'][251]++;
findPotentialLicenseFiles(directory, "**/*readme*", (function (err, readmeFiles) {
_$jscoverage['nlf.js'][254]++;
_$jscoverage['nlf.js'][285]++;
findPotentialLicenseFiles(directory, "*readme*", (function (err, readmeFiles) {
_$jscoverage['nlf.js'][288]++;
if (err) {
_$jscoverage['nlf.js'][255]++;
_$jscoverage['nlf.js'][289]++;
return callback(err);
}
_$jscoverage['nlf.js'][258]++;
_$jscoverage['nlf.js'][292]++;
addFiles(readmeFiles, module.licenseSources.readme, (function (err) {
_$jscoverage['nlf.js'][259]++;
_$jscoverage['nlf.js'][293]++;
var index;
_$jscoverage['nlf.js'][261]++;
_$jscoverage['nlf.js'][295]++;
if (err) {
_$jscoverage['nlf.js'][262]++;
_$jscoverage['nlf.js'][296]++;
return callback(err);
}
_$jscoverage['nlf.js'][267]++;
_$jscoverage['nlf.js'][301]++;
if (moduleData.license) {
_$jscoverage['nlf.js'][268]++;
_$jscoverage['nlf.js'][302]++;
module.licenseSources["package"].add(new PackageSource(moduleData.license));
}
_$jscoverage['nlf.js'][272]++;
_$jscoverage['nlf.js'][306]++;
if (moduleData.licenses) {
_$jscoverage['nlf.js'][273]++;
_$jscoverage['nlf.js'][307]++;
for (index = 0; index < moduleData.licenses.length; index++) {
_$jscoverage['nlf.js'][274]++;
_$jscoverage['nlf.js'][308]++;
module.licenseSources["package"].add(new PackageSource(moduleData.licenses[index]));
}
}
_$jscoverage['nlf.js'][280]++;
_$jscoverage['nlf.js'][314]++;
callback(null, module);

@@ -353,107 +384,124 @@ }));

}
_$jscoverage['nlf.js'][293]++;
_$jscoverage['nlf.js'][327]++;
function convertToArray(object) {
_$jscoverage['nlf.js'][295]++;
_$jscoverage['nlf.js'][329]++;
var propertyName, output = [];
_$jscoverage['nlf.js'][298]++;
_$jscoverage['nlf.js'][332]++;
for (propertyName in object) {
_$jscoverage['nlf.js'][299]++;
_$jscoverage['nlf.js'][333]++;
if (object.hasOwnProperty(propertyName)) {
_$jscoverage['nlf.js'][300]++;
_$jscoverage['nlf.js'][334]++;
output.push(object[propertyName]);
}
}
_$jscoverage['nlf.js'][304]++;
_$jscoverage['nlf.js'][339]++;
output.sort((function (a, b) {
_$jscoverage['nlf.js'][340]++;
if (a.name < b.name) {
_$jscoverage['nlf.js'][341]++;
return -1;
}
_$jscoverage['nlf.js'][343]++;
if (a.name > b.name) {
_$jscoverage['nlf.js'][344]++;
return 1;
}
_$jscoverage['nlf.js'][346]++;
return 0;
}));
_$jscoverage['nlf.js'][349]++;
return output;
}
_$jscoverage['nlf.js'][313]++;
_$jscoverage['nlf.js'][358]++;
function processOptions(options) {
_$jscoverage['nlf.js'][315]++;
_$jscoverage['nlf.js'][360]++;
options = options || {};
_$jscoverage['nlf.js'][317]++;
_$jscoverage['nlf.js'][362]++;
if (typeof options !== "object") {
_$jscoverage['nlf.js'][318]++;
_$jscoverage['nlf.js'][363]++;
throw new Error("options must be an object");
}
_$jscoverage['nlf.js'][321]++;
_$jscoverage['nlf.js'][366]++;
options.directory = options.directory || process.cwd();
_$jscoverage['nlf.js'][322]++;
_$jscoverage['nlf.js'][367]++;
options.production = options.production || false;
_$jscoverage['nlf.js'][324]++;
_$jscoverage['nlf.js'][368]++;
options.depth = typeof options.depth === "number"? options.depth: Infinity;
_$jscoverage['nlf.js'][370]++;
if (typeof options.directory !== "string") {
_$jscoverage['nlf.js'][325]++;
_$jscoverage['nlf.js'][371]++;
throw new Error("options.directory must be a string");
}
_$jscoverage['nlf.js'][328]++;
_$jscoverage['nlf.js'][374]++;
if (typeof options.production !== "boolean") {
_$jscoverage['nlf.js'][329]++;
_$jscoverage['nlf.js'][375]++;
throw new Error("options.production must be a boolean");
}
_$jscoverage['nlf.js'][332]++;
_$jscoverage['nlf.js'][378]++;
return options;
}
_$jscoverage['nlf.js'][342]++;
_$jscoverage['nlf.js'][388]++;
function fileExistsSync(filePath) {
_$jscoverage['nlf.js'][344]++;
_$jscoverage['nlf.js'][390]++;
try {
_$jscoverage['nlf.js'][345]++;
_$jscoverage['nlf.js'][391]++;
var stats = fs.statSync(filePath);
_$jscoverage['nlf.js'][346]++;
_$jscoverage['nlf.js'][392]++;
return stats.isFile();
}
catch (err) {
_$jscoverage['nlf.js'][348]++;
_$jscoverage['nlf.js'][394]++;
if (err.code === "ENOENT") {
_$jscoverage['nlf.js'][349]++;
_$jscoverage['nlf.js'][395]++;
return false;
}
_$jscoverage['nlf.js'][351]++;
_$jscoverage['nlf.js'][397]++;
throw err;
}
}
_$jscoverage['nlf.js'][361]++;
_$jscoverage['nlf.js'][407]++;
function find(options, callback) {
_$jscoverage['nlf.js'][364]++;
_$jscoverage['nlf.js'][410]++;
if (typeof options === "function" && callback === undefined) {
_$jscoverage['nlf.js'][365]++;
_$jscoverage['nlf.js'][411]++;
callback = options;
_$jscoverage['nlf.js'][366]++;
_$jscoverage['nlf.js'][412]++;
options = undefined;
}
_$jscoverage['nlf.js'][369]++;
_$jscoverage['nlf.js'][415]++;
try {
_$jscoverage['nlf.js'][370]++;
_$jscoverage['nlf.js'][416]++;
options = processOptions(options);
}
catch (err) {
_$jscoverage['nlf.js'][372]++;
_$jscoverage['nlf.js'][418]++;
return callback(err);
}
_$jscoverage['nlf.js'][380]++;
_$jscoverage['nlf.js'][426]++;
function log(output) {
_$jscoverage['nlf.js'][381]++;
_$jscoverage['nlf.js'][427]++;
console.error("Error in reading node_module dependencies, error was: " + output);
}
_$jscoverage['nlf.js'][385]++;
_$jscoverage['nlf.js'][431]++;
if (! fileExistsSync(path.join(options.directory, "package.json"))) {
_$jscoverage['nlf.js'][386]++;
_$jscoverage['nlf.js'][432]++;
return callback(new Error("No package.json file found."));
}
_$jscoverage['nlf.js'][390]++;
readInstalled(options.directory, {log: log}, (function (err, data) {
_$jscoverage['nlf.js'][392]++;
_$jscoverage['nlf.js'][436]++;
readInstalled(options.directory, {log: log, depth: options.depth}, (function (err, data) {
_$jscoverage['nlf.js'][441]++;
if (err) {
_$jscoverage['nlf.js'][393]++;
_$jscoverage['nlf.js'][442]++;
console.error("Serious problem reading node_module dependencies");
_$jscoverage['nlf.js'][394]++;
_$jscoverage['nlf.js'][443]++;
return callback(err);
}
_$jscoverage['nlf.js'][398]++;
_$jscoverage['nlf.js'][447]++;
parseInstalled(data, options, (function (err, output) {
_$jscoverage['nlf.js'][400]++;
_$jscoverage['nlf.js'][449]++;
if (err) {
_$jscoverage['nlf.js'][401]++;
_$jscoverage['nlf.js'][450]++;
return callback(err);
}
_$jscoverage['nlf.js'][405]++;
_$jscoverage['nlf.js'][454]++;
callback(null, convertToArray(output));

@@ -463,4 +511,4 @@ }));

}
_$jscoverage['nlf.js'][410]++;
_$jscoverage['nlf.js'][459]++;
module.exports = {"find": find, "Module": Module, "FileSource": FileSource, "PackageSource": PackageSource, "csvFormatter": csvFormatter, "standardFormatter": standardFormatter, "licenseFind": licenseFind, "LicenseCollection": LicenseCollection};
_$jscoverage['nlf.js'].source = ["/**"," *"," * @description Performs license search"," *"," * @author Ian Kelly"," * @copyright Copyright (C) Ian Kelly 2013"," *"," * @license [url] The MIT License"," *"," */","'use strict';","","var readInstalled = require('read-installed'),","\tModule = require('./module'),","\tpath = require('path'),","\tfs = require('fs'),","\tglob = require('glob'),","\tFileSource = require('./file-source'),","\tPackageSource = require('./package-source'),","\tcsvFormatter = require('./formatters/csv'),","\tstandardFormatter = require('./formatters/standard'),","\tLicenseCollection = require('./license-collection'),","\tlicenseFind = require('./license-find'),","\tmatchNodeModules = /node_modules\\//;","","/**"," * Is this module a development dependency of its parent?"," *"," * @param {Object} moduleData The module's data"," * @return {Boolean} True if the module is a production dependency"," */","function isDevDependency(moduleData) {","","\t// this might be the root object - which by definition is production","\tif (moduleData.parent === undefined) {","\t\treturn false;","\t}","","\tvar dependencies = moduleData.parent.devDependencies || {},","\t\tdependencyName;","","\t// look for this module in the production dependencies of the parent","\t// and return true if it is found","\tfor (dependencyName in dependencies) {","\t\tif (dependencies.hasOwnProperty(dependencyName)) {","\t\t\tif (dependencyName === moduleData.name) {","\t\t\t\treturn true;","\t\t\t}","\t\t}","\t}","","\treturn false;","}","","/**"," * Parse the data returned by readInstalled"," *"," * @param {Object}\t\tdata readInstalled data"," * @param {Object}\t\toptions the options object"," * @param {Array}\t\toutput The output array"," * @param {Function}\tcallback Callback function"," */","function parseInstalled(data, options, callback) {","","\t// count of outstanding unfinished parse functions","\tvar count = 0;","","\t/**","\t * Recursively parse some readInstalled module data, including all dependencies","\t *","\t * @param {Object}\t\tmoduleData\tThe module data","\t * @param {Object}\t\toutput\t\tThe output data","\t * @param {Function}\tcallback\tCallback","\t */","\t(function parseModuleData(moduleData, output) {","","\t\t// don't parse this module if it is a development dependency","\t\t// and we are only looking for production dependencies","\t\tif (options.production &amp;&amp; isDevDependency(moduleData)) {","\t\t\treturn;","\t\t}","","\t\t// a module with this ID (name@version) is already in the output","\t\t// collection, we don't need to process it again","\t\tif (!output.hasOwnProperty(moduleData._id)) {","","\t\t\t// we need to lock this ID now in case another function call does this","\t\t\toutput[moduleData._id] = null;","","\t\t\t// we're going to call the async function - so increase count","\t\t\tcount++;","\t\t\tcreateModule(moduleData, function (err, module) {","\t\t\t\t// decrease count when it returns","\t\t\t\tcount--;","","\t\t\t\tif (err) {","\t\t\t\t\treturn callback(err);","\t\t\t\t}","","\t\t\t\t// add this module to the output object/collection","\t\t\t\toutput[moduleData._id] = module;","","\t\t\t\t// iterate over all the dependencies - if any","\t\t\t\tvar dependencies = moduleData.dependencies || {},","\t\t\t\t\tname;","","\t\t\t\tfor (name in dependencies) {","\t\t\t\t\tif (dependencies.hasOwnProperty(name)) {","\t\t\t\t\t\tif (typeof dependencies[name] === 'object') {","\t\t\t\t\t\t\t// this is the normal case where a dependency is an object","\t\t\t\t\t\t\t// recursively parse that object","\t\t\t\t\t\t\tparseModuleData(dependencies[name], output);","\t\t\t\t\t\t} else {","\t\t\t\t\t\t\t// if a module is in the project package.json file but","\t\t\t\t\t\t\t// has not yet been npm installed, it will just be a string and","\t\t\t\t\t\t\t// no futher detail should be","\t\t\t\t\t\t\tconsole.warn('Warning: dependency \"' + name +","\t\t\t\t\t\t\t\t'\" probably not installed.');","\t\t\t\t\t\t\tconsole.warn('please install dependencies from npm before running nlf');","\t\t\t\t\t\t}","\t\t\t\t\t}","\t\t\t\t}","","\t\t\t\t// if count falls to zero, we are finished","\t\t\t\tif (count === 0) {","\t\t\t\t\tcallback(null, output);","\t\t\t\t}","\t\t\t});","\t\t}","","\t})(data, {});","}","","/**"," * Find potential license files - using glob matching"," *"," * @param {String} directory The directory to search in"," * @param {String} pattern The glob pattern to apply"," * @param {Function} callback Callback (err, arrayOfPaths)"," */","function findPotentialLicenseFiles(directory, pattern, callback) {","","\tif (typeof pattern !== 'string') {","\t\treturn callback(new Error('pattern must be a string'));","\t}","","\tif (typeof directory !== 'string') {","\t\treturn callback(new Error('directory must be a string'));","\t}","","\t// glob to find all files that match the pattern","\tglob(pattern, { nocase: true, cwd: directory }, function (err, files) {","","\t\tif (err) {","\t\t\treturn callback(err);","\t\t}","","\t\tvar fileIndex,","\t\t\tmatchedFile,","\t\t\tfound = [];","","\t\tfor (fileIndex = files.length - 1; fileIndex &gt;= 0; fileIndex--) {","\t\t\tmatchedFile = files[fileIndex];","","\t\t\t// exclude files found in node_modules directories","\t\t\tif (matchNodeModules.test(matchedFile)) {","\t\t\t\tcontinue;","\t\t\t}","","\t\t\tvar filePath = path.join(directory, matchedFile);","\t\t\t// check that it is a file","\t\t\tif (fs.statSync(filePath).isFile()) {","\t\t\t\tfound.push(filePath);","\t\t\t}","\t\t}","","\t\tcallback(null, found);","\t});","}","","","/**"," * Add files to a module's collection"," *"," * @param {Array} filePaths Array of file paths"," * @param {Array } collection The collection to add the fileSource objects to"," * @param {Function} callback Callback (err);"," */","function addFiles(filePaths, collection, callback) {","","\t// if this is called with a missing or empty list - just callbacj","\tif (!filePaths || filePaths.length === 0) {","\t\treturn callback(null);","\t}","","\tvar fileIndex,","\t\tpending = filePaths.length,","\t\tsource;","","\t/**","\t * Check whether we have completed the list","\t */","\tfunction checkDone(err) {","\t\tif (err) {","\t\t\tcallback(err);","\t\t}","","\t\tpending--;","\t\tif (!pending) {","\t\t\tcallback(null);","\t\t}","\t}","","\t// iterate over all the file paths","\tfor (fileIndex = 0; fileIndex &lt; filePaths.length; fileIndex++) {","\t\tsource = new FileSource(filePaths[fileIndex]);","\t\tcollection.add(source);","\t\t// read the files","\t\tsource.read(checkDone);","\t}","}","","/**"," * Create a module object from a record in readInstalled"," *"," * @param {Object} moduleData The module data object"," * @param {Function} callback Callback (err, Array of module object)"," */","function createModule(moduleData, callback) {","","\tvar repository = (moduleData.repository || {}).url || '(none)',","\t\tdirectory = moduleData.path,","\t\tmodule = new Module(moduleData._id, moduleData.name,","\t\t\tmoduleData.version, directory, repository);","","\t// glob for license files","\tfindPotentialLicenseFiles(directory, '**/*license*',","\t\tfunction (err, licenseFiles) {","","\t\tif (err) {","\t\t\treturn callback(err);","\t\t}","","\t\taddFiles(licenseFiles, module.licenseSources.license, function (err) {","","\t\t\tif (err) {","\t\t\t\treturn callback(err);","\t\t\t}","","\t\t\t// glob for readme files","\t\t\tfindPotentialLicenseFiles(directory, '**/*readme*',","\t\t\t\tfunction (err, readmeFiles) {","","\t\t\t\tif (err) {","\t\t\t\t\treturn callback(err);","\t\t\t\t}","","\t\t\t\taddFiles(readmeFiles, module.licenseSources.readme, function (err) {","\t\t\t\t\tvar index;","","\t\t\t\t\tif (err) {","\t\t\t\t\t\treturn callback(err);","\t\t\t\t\t}","","\t\t\t\t\t// finally, if there is data in package.json relating to licenses","\t\t\t\t\t// simple license declarations first","\t\t\t\t\tif (moduleData.license) {","\t\t\t\t\t\tmodule.licenseSources.package.add(new PackageSource(moduleData.license));","\t\t\t\t\t}","","\t\t\t\t\t// more complex ones","\t\t\t\t\tif (moduleData.licenses) {","\t\t\t\t\t\tfor (index = 0; index &lt; moduleData.licenses.length; index++) {","\t\t\t\t\t\t\tmodule.licenseSources.package.add(","\t\t\t\t\t\t\t\tnew PackageSource(moduleData.licenses[index])","\t\t\t\t\t\t\t);","\t\t\t\t\t\t}","\t\t\t\t\t}","","\t\t\t\t\tcallback(null, module);","\t\t\t\t});","\t\t\t});","\t\t});","\t});","}","","/**"," * Convert an object to an array"," *"," * @param {Object} object The object"," * @return {Array} An array made from each property of the object"," */","function convertToArray(object) {","","\tvar propertyName,","\t\toutput = [];","","\tfor (propertyName in object) {","\t\tif (object.hasOwnProperty(propertyName)) {","\t\t\toutput.push(object[propertyName]);","\t\t}","\t}","","\treturn output;","}","","/**"," * Process the options"," *"," * @param {Object} options The options object passed into find()"," * @return {Object} Options that have been massaged"," */","function processOptions(options) {","","\toptions = options || {};","","\tif (typeof options !== 'object') {","\t\tthrow new Error('options must be an object');","\t}","","\toptions.directory = options.directory || process.cwd();","\toptions.production = options.production || false;","","\tif (typeof options.directory !== 'string') {","\t\tthrow new Error('options.directory must be a string');","\t}","","\tif (typeof options.production !== 'boolean') {","\t\tthrow new Error('options.production must be a boolean');","\t}","","\treturn options;","}","","","/**"," * Does a file exist?"," *"," * @param {String} filePath The path of the file"," * @return {Boolean} True if the file exists"," */","function fileExistsSync(filePath) {","","\ttry {","\t\tvar stats = fs.statSync(filePath);","\t\treturn stats.isFile();","\t} catch (err) {","\t\tif (err.code === 'ENOENT') {","\t\t\treturn false;","\t\t}","\t\tthrow err;","\t}","}","","/**"," * Function to find licenses"," *"," * @param {Object} options Options object"," * @param {Function} callback Callback function"," */","function find(options, callback) {","","\t// process arguments","\tif (typeof options === 'function' &amp;&amp; callback === undefined) {","\t\tcallback = options;","\t\toptions = undefined;","\t}","","\ttry {","\t\toptions = processOptions(options);","\t} catch (err) {","\t\treturn callback(err);","\t}","","\t/**","\t * Function called when readInstalled hits an issue","\t *","\t * @param {String} output The error message","\t */","\tfunction log(output) {","\t\tconsole.error('Error in reading node_module dependencies, error was: '","\t\t\t+ output);","\t}","","\tif (!fileExistsSync(path.join(options.directory, 'package.json'))) {","\t\treturn callback(new Error('No package.json file found.'));","\t}","","\t// use npm read-installed module to search out all the node modules","\treadInstalled(options.directory, { log: log }, function (err, data) {","","\t\tif (err) {","\t\t\tconsole.error('Serious problem reading node_module dependencies');","\t\t\treturn callback(err);","\t\t}","","\t\t// parse the read-installed data","\t\tparseInstalled(data, options, function (err, output) {","","\t\t\tif (err) {","\t\t\t\treturn callback(err);","\t\t\t}","","\t\t\t// return the output","\t\t\tcallback(null, convertToArray(output));","\t\t});","\t});","}","","module.exports = {","\t'find': find,","\t'Module': Module,","\t'FileSource': FileSource,","\t'PackageSource': PackageSource,","\t'csvFormatter': csvFormatter,","\t'standardFormatter': standardFormatter,","\t'licenseFind': licenseFind,","\t'LicenseCollection': LicenseCollection","};"];
_$jscoverage['nlf.js'].source = ["/**"," *"," * @description Performs license search"," *"," * @author Ian Kelly"," * @copyright Copyright (C) Ian Kelly 2013"," *"," * @license [url] The MIT License"," *"," */","'use strict';","","var readInstalled = require('read-installed'),","\tModule = require('./module'),","\tpath = require('path'),","\tfs = require('fs'),","\tglob = require('glob-all'),","\tFileSource = require('./file-source'),","\tPackageSource = require('./package-source'),","\tcsvFormatter = require('./formatters/csv'),","\tstandardFormatter = require('./formatters/standard'),","\tLicenseCollection = require('./license-collection'),","\tlicenseFind = require('./license-find');","","/**"," * Is this module a development dependency of its parent?"," *"," * @param {Object} moduleData The module's data"," * @return {Boolean} True if the module is a production dependency"," */","function isDevDependency(moduleData) {","","\t// this might be the root object - which by definition is production","\tif (moduleData.parent === undefined) {","\t\treturn false;","\t}","","\tvar dependencies = moduleData.parent.devDependencies || {},","\t\tdependencyName;","","\t// look for this module in the production dependencies of the parent","\t// and return true if it is found","\tfor (dependencyName in dependencies) {","\t\tif (dependencies.hasOwnProperty(dependencyName)) {","\t\t\tif (dependencyName === moduleData.name) {","\t\t\t\treturn true;","\t\t\t}","\t\t}","\t}","","\treturn false;","}","","/**"," * Parse the data returned by readInstalled"," *"," * @param {Object}\t\tdata readInstalled data"," * @param {Object}\t\toptions the options object"," * @param {Array}\t\toutput The output array"," * @param {Function}\tcallback Callback function"," */","function parseInstalled(data, options, callback) {","","\t// count of outstanding unfinished parse functions","\tvar count = 0;","","\t/**","\t * Recursively parse some readInstalled module data, including all dependencies","\t *","\t * @param {Object}\t\tmoduleData\tThe module data","\t * @param {Object}\t\toutput\t\tThe output data","\t * @param {Function}\tcallback\tCallback","\t */","\t(function parseModuleData(moduleData, output) {","","\t\t// don't parse this module if it is a development dependency","\t\t// and we are only looking for production dependencies","\t\tif (options.production &amp;&amp; isDevDependency(moduleData)) {","\t\t\treturn;","\t\t}","","\t\t// a module with this ID (name@version) is already in the output","\t\t// collection, we don't need to process it again","\t\tif (!output.hasOwnProperty(moduleData._id)) {","","\t\t\t// we need to lock this ID now in case another function call does this","\t\t\toutput[moduleData._id] = null;","","\t\t\t// we're going to call the async function - so increase count","\t\t\tcount++;","\t\t\tcreateModule(moduleData, function (err, module) {","\t\t\t\t// decrease count when it returns","\t\t\t\tcount--;","","\t\t\t\tif (err) {","\t\t\t\t\treturn callback(err);","\t\t\t\t}","","\t\t\t\t// add this module to the output object/collection","\t\t\t\toutput[moduleData._id] = module;","","\t\t\t\t// iterate over all the dependencies - if any","\t\t\t\tvar dependencies = moduleData.dependencies || {},","\t\t\t\t\tname;","","\t\t\t\tfor (name in dependencies) {","\t\t\t\t\tif (dependencies.hasOwnProperty(name)) {","\t\t\t\t\t\tif (typeof dependencies[name] === 'object') {","\t\t\t\t\t\t\t// this is the normal case where a dependency is an object","\t\t\t\t\t\t\t// recursively parse that object","\t\t\t\t\t\t\tparseModuleData(dependencies[name], output);","\t\t\t\t\t\t} else {","\t\t\t\t\t\t\t// if a module is in the project package.json file but","\t\t\t\t\t\t\t// has not yet been npm installed, it will just be a string and","\t\t\t\t\t\t\t// no futher detail should be","\t\t\t\t\t\t\tconsole.warn('Warning: dependency \"' + name +","\t\t\t\t\t\t\t\t'\" probably not installed.');","\t\t\t\t\t\t\tconsole.warn('please install dependencies from npm before running nlf');","\t\t\t\t\t\t}","\t\t\t\t\t}","\t\t\t\t}","","\t\t\t\t// if count falls to zero, we are finished","\t\t\t\tif (count === 0) {","\t\t\t\t\tcallback(null, output);","\t\t\t\t}","\t\t\t});","\t\t}","","\t})(data, {});","}","","/**"," * Perform a glob search, but specifically ignoring"," * the node_modules folder, and not using the glob"," * 'ignore' as this is just a final filter on the result"," * and is very slow"," *"," * @param {String} directory The path of the directory to search from"," * @param {String} filePattern A glob file pattern, e.g. *.js"," * @param {Function} callback (err, results)"," */","function globIgnoringModules(directory, filePattern, callback) {","","\t// find all the subdirectories, but ignoring the node modules","\tglob('*/', {","\t\tcwd: directory,","\t\tignore: 'node_modules/'","\t}, function(err, subdirs) {","","\t\tif (err) {","\t\t\treturn callback(err);","\t\t}","","\t\t// convert the directories into individual glob patterns","\t\tvar globpatterns = [];","\t\tfor (var index = 0; index &lt; subdirs.length; index++) {","\t\t\tglobpatterns.push(subdirs[index] + '**/' + filePattern);","\t\t}","","\t\t// add a pattern for the root directory","\t\tglobpatterns.push(filePattern);","","\t\t// now do the glob proper","\t\tglob(globpatterns, {","\t\t\tnocase: true,","\t\t\tcwd: directory","\t\t}, callback);","","\t});","}","","/**"," * Find potential license files - using glob matching"," *"," * @param {String} directory The directory to search in"," * @param {String} pattern The glob pattern to apply"," * @param {Function} callback Callback (err, arrayOfPaths)"," */","function findPotentialLicenseFiles(directory, pattern, callback) {","","\tif (typeof pattern !== 'string') {","\t\treturn callback(new Error('pattern must be a string'));","\t}","","\tif (typeof directory !== 'string') {","\t\treturn callback(new Error('directory must be a string'));","\t}","","\t// glob to find all files that match the pattern","\tglobIgnoringModules(directory, pattern, function (err, files) {","","\t\tif (err) {","\t\t\treturn callback(err);","\t\t}","","\t\tvar fileIndex,","\t\t\tmatchedFile,","\t\t\tfound = [];","","\t\tfor (fileIndex = files.length - 1; fileIndex &gt;= 0; fileIndex--) {","\t\t\tmatchedFile = files[fileIndex];","","\t\t\tvar filePath = path.join(directory, matchedFile);","\t\t\t// check that it is a file","\t\t\tif (fs.statSync(filePath).isFile()) {","\t\t\t\tfound.push(filePath);","\t\t\t}","\t\t}","","\t\tcallback(null, found);","\t});","}","","","/**"," * Add files to a module's collection"," *"," * @param {Array} filePaths Array of file paths"," * @param {Array } collection The collection to add the fileSource objects to"," * @param {Function} callback Callback (err);"," */","function addFiles(filePaths, collection, callback) {","","\t// if this is called with a missing or empty list - just callback","\tif (!filePaths || filePaths.length === 0) {","\t\treturn callback(null);","\t}","","\tvar fileIndex,","\t\tpending = filePaths.length,","\t\tsource;","","\t/**","\t * Check whether we have completed the list","\t */","\tfunction checkDone(err) {","\t\tif (err) {","\t\t\tcallback(err);","\t\t}","","\t\tpending--;","\t\tif (!pending) {","\t\t\tcallback(null);","\t\t}","\t}","","\t// iterate over all the file paths","\tfor (fileIndex = 0; fileIndex &lt; filePaths.length; fileIndex++) {","\t\tsource = new FileSource(filePaths[fileIndex]);","\t\tcollection.add(source);","\t\t// read the files","\t\tsource.read(checkDone);","\t}","}","","/**"," * Create a module object from a record in readInstalled"," *"," * @param {Object} moduleData The module data object"," * @param {Function} callback Callback (err, Array of module object)"," */","function createModule(moduleData, callback) {","","\tvar repository = (moduleData.repository || {}).url || '(none)',","\t\tdirectory = moduleData.path,","\t\tmodule = new Module(moduleData._id, moduleData.name,","\t\t\tmoduleData.version, directory, repository);","","\t// glob for license files","\tfindPotentialLicenseFiles(directory, '*license*',","\t\tfunction (err, licenseFiles) {","","\t\tif (err) {","\t\t\treturn callback(err);","\t\t}","","\t\taddFiles(licenseFiles, module.licenseSources.license, function (err) {","","\t\t\tif (err) {","\t\t\t\treturn callback(err);","\t\t\t}","","\t\t\t// glob for readme files","\t\t\tfindPotentialLicenseFiles(directory, '*readme*',","\t\t\t\tfunction (err, readmeFiles) {","","\t\t\t\tif (err) {","\t\t\t\t\treturn callback(err);","\t\t\t\t}","","\t\t\t\taddFiles(readmeFiles, module.licenseSources.readme, function (err) {","\t\t\t\t\tvar index;","","\t\t\t\t\tif (err) {","\t\t\t\t\t\treturn callback(err);","\t\t\t\t\t}","","\t\t\t\t\t// finally, if there is data in package.json relating to licenses","\t\t\t\t\t// simple license declarations first","\t\t\t\t\tif (moduleData.license) {","\t\t\t\t\t\tmodule.licenseSources.package.add(new PackageSource(moduleData.license));","\t\t\t\t\t}","","\t\t\t\t\t// more complex ones","\t\t\t\t\tif (moduleData.licenses) {","\t\t\t\t\t\tfor (index = 0; index &lt; moduleData.licenses.length; index++) {","\t\t\t\t\t\t\tmodule.licenseSources.package.add(","\t\t\t\t\t\t\t\tnew PackageSource(moduleData.licenses[index])","\t\t\t\t\t\t\t);","\t\t\t\t\t\t}","\t\t\t\t\t}","","\t\t\t\t\tcallback(null, module);","\t\t\t\t});","\t\t\t});","\t\t});","\t});","}","","/**"," * Convert an object to an array"," *"," * @param {Object} object The object"," * @return {Array} An array made from each property of the object"," */","function convertToArray(object) {","","\tvar propertyName,","\t\toutput = [];","","\tfor (propertyName in object) {","\t\tif (object.hasOwnProperty(propertyName)) {","\t\t\toutput.push(object[propertyName]);","\t\t}","\t}","","\t// sort the array","\toutput.sort(function(a, b) {","\t\tif (a.name &lt; b.name) {","\t\t\treturn -1;","\t\t}","\t\tif (a.name &gt; b.name) {","\t\t\treturn 1;","\t\t}","\t\treturn 0;","\t});","","\treturn output;","}","","/**"," * Process the options"," *"," * @param {Object} options The options object passed into find()"," * @return {Object} Options that have been massaged"," */","function processOptions(options) {","","\toptions = options || {};","","\tif (typeof options !== 'object') {","\t\tthrow new Error('options must be an object');","\t}","","\toptions.directory = options.directory || process.cwd();","\toptions.production = options.production || false;","\toptions.depth = typeof options.depth === 'number' ? options.depth : Infinity;","","\tif (typeof options.directory !== 'string') {","\t\tthrow new Error('options.directory must be a string');","\t}","","\tif (typeof options.production !== 'boolean') {","\t\tthrow new Error('options.production must be a boolean');","\t}","","\treturn options;","}","","","/**"," * Does a file exist?"," *"," * @param {String} filePath The path of the file"," * @return {Boolean} True if the file exists"," */","function fileExistsSync(filePath) {","","\ttry {","\t\tvar stats = fs.statSync(filePath);","\t\treturn stats.isFile();","\t} catch (err) {","\t\tif (err.code === 'ENOENT') {","\t\t\treturn false;","\t\t}","\t\tthrow err;","\t}","}","","/**"," * Function to find licenses"," *"," * @param {Object} options Options object"," * @param {Function} callback Callback function"," */","function find(options, callback) {","","\t// process arguments","\tif (typeof options === 'function' &amp;&amp; callback === undefined) {","\t\tcallback = options;","\t\toptions = undefined;","\t}","","\ttry {","\t\toptions = processOptions(options);","\t} catch (err) {","\t\treturn callback(err);","\t}","","\t/**","\t * Function called when readInstalled hits an issue","\t *","\t * @param {String} output The error message","\t */","\tfunction log(output) {","\t\tconsole.error('Error in reading node_module dependencies, error was: '","\t\t\t+ output);","\t}","","\tif (!fileExistsSync(path.join(options.directory, 'package.json'))) {","\t\treturn callback(new Error('No package.json file found.'));","\t}","","\t// use npm read-installed module to search out all the node modules","\treadInstalled(options.directory, {","\t\tlog: log,","\t\tdepth: options.depth","\t}, function (err, data) {","","\t\tif (err) {","\t\t\tconsole.error('Serious problem reading node_module dependencies');","\t\t\treturn callback(err);","\t\t}","","\t\t// parse the read-installed data","\t\tparseInstalled(data, options, function (err, output) {","","\t\t\tif (err) {","\t\t\t\treturn callback(err);","\t\t\t}","","\t\t\t// return the output","\t\t\tcallback(null, convertToArray(output));","\t\t});","\t});","}","","module.exports = {","\t'find': find,","\t'Module': Module,","\t'FileSource': FileSource,","\t'PackageSource': PackageSource,","\t'csvFormatter': csvFormatter,","\t'standardFormatter': standardFormatter,","\t'licenseFind': licenseFind,","\t'LicenseCollection': LicenseCollection","};"];

@@ -17,3 +17,3 @@ /**

fs = require('fs'),
glob = require('glob'),
glob = require('glob-all'),
FileSource = require('./file-source'),

@@ -24,4 +24,3 @@ PackageSource = require('./package-source'),

LicenseCollection = require('./license-collection'),
licenseFind = require('./license-find'),
matchNodeModules = /node_modules\//;
licenseFind = require('./license-find');

@@ -137,2 +136,42 @@ /**

/**
* Perform a glob search, but specifically ignoring
* the node_modules folder, and not using the glob
* 'ignore' as this is just a final filter on the result
* and is very slow
*
* @param {String} directory The path of the directory to search from
* @param {String} filePattern A glob file pattern, e.g. *.js
* @param {Function} callback (err, results)
*/
function globIgnoringModules(directory, filePattern, callback) {
// find all the subdirectories, but ignoring the node modules
glob('*/', {
cwd: directory,
ignore: 'node_modules/'
}, function(err, subdirs) {
if (err) {
return callback(err);
}
// convert the directories into individual glob patterns
var globpatterns = [];
for (var index = 0; index < subdirs.length; index++) {
globpatterns.push(subdirs[index] + '**/' + filePattern);
}
// add a pattern for the root directory
globpatterns.push(filePattern);
// now do the glob proper
glob(globpatterns, {
nocase: true,
cwd: directory
}, callback);
});
}
/**
* Find potential license files - using glob matching

@@ -155,3 +194,3 @@ *

// glob to find all files that match the pattern
glob(pattern, { nocase: true, cwd: directory }, function (err, files) {
globIgnoringModules(directory, pattern, function (err, files) {

@@ -169,7 +208,2 @@ if (err) {

// exclude files found in node_modules directories
if (matchNodeModules.test(matchedFile)) {
continue;
}
var filePath = path.join(directory, matchedFile);

@@ -242,3 +276,3 @@ // check that it is a file

// glob for license files
findPotentialLicenseFiles(directory, '**/*license*',
findPotentialLicenseFiles(directory, '*license*',
function (err, licenseFiles) {

@@ -257,3 +291,3 @@

// glob for readme files
findPotentialLicenseFiles(directory, '**/*readme*',
findPotentialLicenseFiles(directory, '*readme*',
function (err, readmeFiles) {

@@ -311,2 +345,13 @@

// sort the array
output.sort(function(a, b) {
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
});
return output;

@@ -313,0 +358,0 @@ }

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

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

@@ -18,12 +18,11 @@ "bin": {

"dependencies": {
"archy": "0.0.2",
"commander": "^2.3.0",
"glob": "^4.0.2",
"read-installed": "^3.0.0"
"archy": "1.0.0",
"commander": "2.7.1",
"glob-all": "3.0.1",
"read-installed": "3.1.5"
},
"devDependencies": {
"globs": "^0.1.2",
"jshint": "~2.5.1",
"mocha": "^1.21.4",
"should": "^4.0.4"
"jshint": "^2.6.3",
"mocha": "^2.2.1",
"should": "^5.2.0"
},

@@ -30,0 +29,0 @@ "engines": {

@@ -42,8 +42,8 @@ <!-- @@NLF-IGNORE@@ -->

<pre>
archy@0.0.2 [license(s): MIT/X11]
└── package.json: MIT/X11
commander@0.6.1 [license(s): MIT]
└── readme files: MIT
read-installed@0.2.2 [license(s): BSD]
└── license files: BSD
glob@3.2.3 [license(s): BSD]

@@ -53,5 +53,2 @@ ├── package.json: BSD

archy@0.0.2 [license(s): MIT/X11]
└── package.json: MIT/X11
json-stringify-safe@5.0.0 [license(s): BSD]

@@ -61,2 +58,5 @@ ├── package.json: BSD

read-installed@0.2.2 [license(s): BSD]
└── license files: BSD
should@1.2.2 [license(s): MIT]

@@ -158,3 +158,3 @@ └── readme files: MIT

Copyright (c) 2013 Ian Kelly
Copyright (c) 2013-2015 Ian Kelly

@@ -178,2 +178,1 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

THE SOFTWARE.

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