Comparing version 0.2.5 to 0.2.6
@@ -66,2 +66,2 @@ /* automatically generated by JSCoverage - do not edit */ | ||
module.exports = FileSource; | ||
_$jscoverage['file-source.js'].source = ["/**"," * @description A file source for a potential license"," *"," * @author Ian Kelly"," * @copyright Copyright (C) Ian Kelly 2013"," *"," * @license The MIT License"," */","","'use strict';","","var licenseFind = require('./license-find'),","\tfs = require('fs');","","/**"," * Constructor"," * "," * @param {String} filePath Path of the file"," * @returns {Object} \t\tThe FileSource object"," */","function FileSource(filePath) {","","\tif (typeof filePath !== 'string') {","\t\tthrow new Error('filePath must be a string');","\t}","","\tthis.filePath = filePath;","\tthis.text = '';","","\treturn this;","}","","/**"," * Read the file"," * "," * @param {Function} callback Callback (err)"," */","FileSource.prototype.read = function (callback) {","","\tvar self = this;","","\tfs.readFile(this.filePath, 'utf-8', function (err, data) {","\t\tif (err) {","\t\t\treturn callback(err);","\t\t}","","\t\tself.text = data;","\t\tcallback(null);","\t});","};","","/**"," * Returns which licenses this file potentially declares"," * "," * @return {Array} Array of license name strings"," */","FileSource.prototype.names = function () {","","\treturn licenseFind(this.text);","","};","","","module.exports = FileSource;"]; | ||
_$jscoverage['file-source.js'].source = ["/**"," * @description A file source for a potential license"," *"," * @author Ian Kelly"," * @copyright Copyright (C) Ian Kelly 2013"," *"," * @license The MIT License"," */","","'use strict';","","var licenseFind = require('./license-find'),","\tfs = require('fs');","","/**"," * Constructor"," * "," * @param {String} filePath Path of the file"," * @returns {Object}\t\tThe FileSource object"," */","function FileSource(filePath) {","","\tif (typeof filePath !== 'string') {","\t\tthrow new Error('filePath must be a string');","\t}","","\tthis.filePath = filePath;","\tthis.text = '';","","\treturn this;","}","","/**"," * Read the file"," * "," * @param {Function} callback Callback (err)"," */","FileSource.prototype.read = function (callback) {","","\tvar self = this;","","\tfs.readFile(this.filePath, 'utf-8', function (err, data) {","\t\tif (err) {","\t\t\treturn callback(err);","\t\t}","","\t\tself.text = data;","\t\tcallback(null);","\t});","};","","/**"," * Returns which licenses this file potentially declares"," * "," * @return {Array} Array of license name strings"," */","FileSource.prototype.names = function () {","","\treturn licenseFind(this.text);","","};","","","module.exports = FileSource;"]; |
@@ -35,15 +35,15 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['formatters/csv.js'][43]++; | ||
if (! Array.isArray(licenseData)) { | ||
if (typeof callback !== "function") { | ||
_$jscoverage['formatters/csv.js'][44]++; | ||
return callback(new Error("licenseData must be an array")); | ||
throw new Error("must have a callback"); | ||
} | ||
_$jscoverage['formatters/csv.js'][47]++; | ||
if (licenseData.length < 1) { | ||
if (! Array.isArray(licenseData)) { | ||
_$jscoverage['formatters/csv.js'][48]++; | ||
return callback(new Error("must have at least one module in data")); | ||
return callback(new Error("licenseData must be an array")); | ||
} | ||
_$jscoverage['formatters/csv.js'][51]++; | ||
if (typeof callback !== "function") { | ||
if (licenseData.length < 1) { | ||
_$jscoverage['formatters/csv.js'][52]++; | ||
return callback(new Error("must have a callback")); | ||
return callback(new Error("must have at least one module in data")); | ||
} | ||
@@ -64,2 +64,2 @@ _$jscoverage['formatters/csv.js'][55]++; | ||
module.exports = {render: render}; | ||
_$jscoverage['formatters/csv.js'].source = ["/**"," * @description csv output formatter"," * @author Ian Kelly"," *"," * @copyright Copyright (C) Ian Kelly 2013"," * @license MIT"," */","","'use strict';","","var heading = 'name,version,directory,repository,summary,' +","\t\t\t'from package.json,from license,from readme';","","","/**"," * Returns a single csv line for a module record"," * "," * @param {Object} moduleRecord The module's license record"," * @return {String} The record turned into a CSV record"," */","function recordToCsv(moduleRecord) {","","\t// @todo - what do do if any of the data contains a comma?","\t// put double quotes around the value?","\treturn moduleRecord.name + ',' +","\t\t\tmoduleRecord.version + ',' +","\t\t\tmoduleRecord.directory + ',' +","\t\t\tmoduleRecord.repository + ',' +","\t\t\tmoduleRecord.summary().join(';') + ',' +","\t\t\tmoduleRecord.licenseSources.package.summary().join(';') + ',' +","\t\t\tmoduleRecord.licenseSources.license.summary().join(';') + ',' +","\t\t\tmoduleRecord.licenseSources.readme.summary().join(';');","}","","/**"," * Render the license data"," * "," * @param {Array} licenseData An array of module licence data"," * @param {Function} callback The callback (err, output string)"," */","function render(licenseData, callback) {","","\tif (!Array.isArray(licenseData)) {","\t\treturn callback(new Error('licenseData must be an array'));","\t}","","\tif (licenseData.length < 1) {","\t\treturn callback(new Error('must have at least one module in data'));","\t}","","\tif (typeof callback !== 'function') {","\t\treturn callback(new Error('must have a callback'));","\t}","","\tvar output = [];","","\toutput.push(heading);","","\tlicenseData.forEach(function (module) {","\t\toutput.push(recordToCsv(module));","\t});","","\tcallback(null, output.join('\\n'));","}","","","module.exports = {","\trender: render","};"]; | ||
_$jscoverage['formatters/csv.js'].source = ["/**"," * @description csv output formatter"," * @author Ian Kelly"," *"," * @copyright Copyright (C) Ian Kelly 2013"," * @license MIT"," */","","'use strict';","","var heading = 'name,version,directory,repository,summary,' +","\t\t\t'from package.json,from license,from readme';","","","/**"," * Returns a single csv line for a module record"," * "," * @param {Object} moduleRecord The module's license record"," * @return {String} The record turned into a CSV record"," */","function recordToCsv(moduleRecord) {","","\t// @todo - what do do if any of the data contains a comma?","\t// put double quotes around the value?","\treturn moduleRecord.name + ',' +","\t\t\tmoduleRecord.version + ',' +","\t\t\tmoduleRecord.directory + ',' +","\t\t\tmoduleRecord.repository + ',' +","\t\t\tmoduleRecord.summary().join(';') + ',' +","\t\t\tmoduleRecord.licenseSources.package.summary().join(';') + ',' +","\t\t\tmoduleRecord.licenseSources.license.summary().join(';') + ',' +","\t\t\tmoduleRecord.licenseSources.readme.summary().join(';');","}","","/**"," * Render the license data"," * "," * @param {Array} licenseData An array of module licence data"," * @param {Function} callback The callback (err, output string)"," */","function render(licenseData, callback) {","","\tif (typeof callback !== 'function') {","\t\tthrow new Error('must have a callback');","\t}","","\tif (!Array.isArray(licenseData)) {","\t\treturn callback(new Error('licenseData must be an array'));","\t}","","\tif (licenseData.length < 1) {","\t\treturn callback(new Error('must have at least one module in data'));","\t}","","\tvar output = [];","","\toutput.push(heading);","","\tlicenseData.forEach(function (module) {","\t\toutput.push(recordToCsv(module));","\t});","","\tcallback(null, output.join('\\n'));","}","","","module.exports = {","\trender: render","};"]; |
@@ -67,15 +67,15 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['formatters/standard.js'][57]++; | ||
if (! Array.isArray(licenseData)) { | ||
if (typeof callback !== "function") { | ||
_$jscoverage['formatters/standard.js'][58]++; | ||
return callback(new Error("licenseData must be an array")); | ||
throw new Error("must have a callback"); | ||
} | ||
_$jscoverage['formatters/standard.js'][61]++; | ||
if (licenseData.length < 1) { | ||
if (! Array.isArray(licenseData)) { | ||
_$jscoverage['formatters/standard.js'][62]++; | ||
return callback(new Error("must have at least one module in data")); | ||
return callback(new Error("licenseData must be an array")); | ||
} | ||
_$jscoverage['formatters/standard.js'][65]++; | ||
if (typeof callback !== "function") { | ||
if (licenseData.length < 1) { | ||
_$jscoverage['formatters/standard.js'][66]++; | ||
return callback(new Error("must have a callback")); | ||
return callback(new Error("must have at least one module in data")); | ||
} | ||
@@ -94,2 +94,2 @@ _$jscoverage['formatters/standard.js'][69]++; | ||
module.exports = {render: render}; | ||
_$jscoverage['formatters/standard.js'].source = ["/**"," * @description Standard console output formatter"," * @author Ian Kelly"," *"," * @copyright Copyright (C) Ian Kelly 2013"," * @license MIT"," */","","'use strict';","","var archy = require('archy');","","/**"," * Create the output string for a single module"," * "," * @param {Object} moduleData The module license data"," * @return {String} An archy formatted string"," */","function createModuleNode(moduleData) {","","\tvar output = {","\t\tlabel: moduleData.id","\t\t\t+ ' [license(s): '","\t\t\t+ moduleData.summary().join(', ')","\t\t\t+ ']',","\t\tnodes: []","\t},","\t\tsummary;","","\tsummary = moduleData.licenseSources.package.summary();","\tif (summary.length > 0) {","\t\toutput.nodes.push('package.json: ' + summary.join(', '));","\t}","","\tsummary = moduleData.licenseSources.license.summary();","\tif (summary.length > 0) {","\t\toutput.nodes.push('license files: ' + summary.join(', '));","\t}","","\tsummary = moduleData.licenseSources.readme.summary();","\tif (summary.length > 0) {","\t\toutput.nodes.push('readme files: ' + summary.join(', '));","\t}","","\treturn archy(output);","}","","","/**"," * Render the license data"," * "," * @param {Array} licenseData An array of module licence data"," * @param {Function} callback The callback (err, output string)"," */","function render(licenseData, callback) {","","\tif (!Array.isArray(licenseData)) {","\t\treturn callback(new Error('licenseData must be an array'));","\t}","","\tif (licenseData.length < 1) {","\t\treturn callback(new Error('must have at least one module in data'));","\t}","","\tif (typeof callback !== 'function') {","\t\treturn callback(new Error('must have a callback'));","\t}","","\tvar output = [];","","\tlicenseData.forEach(function (module) {","\t\toutput.push(createModuleNode(module));","\t});","","\tcallback(null, output.join('\\n'));","}","","","module.exports = {","\trender: render","};"]; | ||
_$jscoverage['formatters/standard.js'].source = ["/**"," * @description Standard console output formatter"," * @author Ian Kelly"," *"," * @copyright Copyright (C) Ian Kelly 2013"," * @license MIT"," */","","'use strict';","","var archy = require('archy');","","/**"," * Create the output string for a single module"," * "," * @param {Object} moduleData The module license data"," * @return {String} An archy formatted string"," */","function createModuleNode(moduleData) {","","\tvar output = {","\t\tlabel: moduleData.id","\t\t\t+ ' [license(s): '","\t\t\t+ moduleData.summary().join(', ')","\t\t\t+ ']',","\t\tnodes: []","\t},","\t\tsummary;","","\tsummary = moduleData.licenseSources.package.summary();","\tif (summary.length > 0) {","\t\toutput.nodes.push('package.json: ' + summary.join(', '));","\t}","","\tsummary = moduleData.licenseSources.license.summary();","\tif (summary.length > 0) {","\t\toutput.nodes.push('license files: ' + summary.join(', '));","\t}","","\tsummary = moduleData.licenseSources.readme.summary();","\tif (summary.length > 0) {","\t\toutput.nodes.push('readme files: ' + summary.join(', '));","\t}","","\treturn archy(output);","}","","","/**"," * Render the license data"," * "," * @param {Array} licenseData An array of module licence data"," * @param {Function} callback The callback (err, output string)"," */","function render(licenseData, callback) {","","\tif (typeof callback !== 'function') {","\t\tthrow new Error('must have a callback');","\t}","","\tif (!Array.isArray(licenseData)) {","\t\treturn callback(new Error('licenseData must be an array'));","\t}","","\tif (licenseData.length < 1) {","\t\treturn callback(new Error('must have at least one module in data'));","\t}","","\tvar output = [];","","\tlicenseData.forEach(function (module) {","\t\toutput.push(createModuleNode(module));","\t});","","\tcallback(null, output.join('\\n'));","}","","","module.exports = {","\trender: render","};"]; |
@@ -7,13 +7,13 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['license-find.js'][16] = 0; | ||
_$jscoverage['license-find.js'][71] = 0; | ||
_$jscoverage['license-find.js'][73] = 0; | ||
_$jscoverage['license-find.js'][79] = 0; | ||
_$jscoverage['license-find.js'][80] = 0; | ||
_$jscoverage['license-find.js'][81] = 0; | ||
_$jscoverage['license-find.js'][82] = 0; | ||
_$jscoverage['license-find.js'][83] = 0; | ||
_$jscoverage['license-find.js'][84] = 0; | ||
_$jscoverage['license-find.js'][85] = 0; | ||
_$jscoverage['license-find.js'][91] = 0; | ||
_$jscoverage['license-find.js'][86] = 0; | ||
_$jscoverage['license-find.js'][88] = 0; | ||
_$jscoverage['license-find.js'][94] = 0; | ||
_$jscoverage['license-find.js'][95] = 0; | ||
_$jscoverage['license-find.js'][96] = 0; | ||
_$jscoverage['license-find.js'][97] = 0; | ||
_$jscoverage['license-find.js'][98] = 0; | ||
_$jscoverage['license-find.js'][99] = 0; | ||
_$jscoverage['license-find.js'][100] = 0; | ||
_$jscoverage['license-find.js'][106] = 0; | ||
_$jscoverage['license-find.js'][109] = 0; | ||
} | ||
@@ -23,20 +23,20 @@ _$jscoverage['license-find.js'][14]++; | ||
_$jscoverage['license-find.js'][16]++; | ||
var patterns = [{"name": "BSD", "regex": [/\sBSD\s/]}, {"name": "GPL", "regex": [/\sGPL\s/, /\sGPLv2\s/]}, {"name": "LGPL", "regex": [/\sLGPL\s/]}, {"name": "MIT", "regex": [/\sMIT\s/, /\s\(MIT\)\s/]}, {"name": "Apache", "regex": [/\sApache\sLicen[cs]e\s/i]}, {"name": "MPL", "regex": [/\sMPL\s/]}, {"name": "WTFPL", "regex": [/\sDO\sWHAT\sTHE\sFUCK\sYOU\sWANT\sTO\sPUBLIC\sLICEN[CS]E\s/i]}], excludePattern = /@@NLF-IGNORE@@/; | ||
_$jscoverage['license-find.js'][71]++; | ||
var patterns = [{"name": "BSD", "regex": [/(?:^|\s)BSD\s/]}, {"name": "GPL", "regex": [/(?:^|\s)GPL\s/, /(?:^|\s)GPLv\d\s/]}, {"name": "LGPL", "regex": [/(?:^|\s)LGPL\s/]}, {"name": "MIT", "regex": [/(?:^|\s)MIT\s/, /(?:^|\s)\(MIT\)\s/]}, {"name": "Apache", "regex": [/(?:^|\s)Apache\sLicen[cs]e\s/i]}, {"name": "MPL", "regex": [/(?:^|\s)MPL\s/]}, {"name": "WTFPL", "regex": [/(?:^|\s)WTFPL\s/, /(?:^|\s)DO\sWHAT\sTHE\sFUCK\sYOU\sWANT\sTO\sPUBLIC\sLICEN[CS]E\s/i]}, {"name": "ISC", "regex": [/(?:^|\s)ISC\s/, /(?:^|\s)\(ISC\)\s/]}, {"name": "Eclipse Public License", "regex": [/(?:^|\s)Eclipse\sPublic\sLicen[cs]e\s/i, /(?:^|\s)EPL\s/, /(?:(?:^|\s)|\()EPL-1\.0(?:\)|\s)/]}], excludePattern = /@@NLF-IGNORE@@/; | ||
_$jscoverage['license-find.js'][86]++; | ||
function identifyLicense(text) { | ||
_$jscoverage['license-find.js'][73]++; | ||
_$jscoverage['license-find.js'][88]++; | ||
var licenseIndex, regexIndex, pattern, output = []; | ||
_$jscoverage['license-find.js'][79]++; | ||
_$jscoverage['license-find.js'][94]++; | ||
if (! excludePattern.test(text)) { | ||
_$jscoverage['license-find.js'][80]++; | ||
_$jscoverage['license-find.js'][95]++; | ||
for (licenseIndex = patterns.length - 1; licenseIndex >= 0; licenseIndex--) { | ||
_$jscoverage['license-find.js'][81]++; | ||
_$jscoverage['license-find.js'][96]++; | ||
pattern = patterns[licenseIndex]; | ||
_$jscoverage['license-find.js'][82]++; | ||
_$jscoverage['license-find.js'][97]++; | ||
for (regexIndex = pattern.regex.length - 1; regexIndex >= 0; regexIndex--) { | ||
_$jscoverage['license-find.js'][83]++; | ||
_$jscoverage['license-find.js'][98]++; | ||
if (pattern.regex[regexIndex].test(text)) { | ||
_$jscoverage['license-find.js'][84]++; | ||
_$jscoverage['license-find.js'][99]++; | ||
output.push(pattern.name); | ||
_$jscoverage['license-find.js'][85]++; | ||
_$jscoverage['license-find.js'][100]++; | ||
break; | ||
@@ -47,7 +47,7 @@ } | ||
} | ||
_$jscoverage['license-find.js'][91]++; | ||
_$jscoverage['license-find.js'][106]++; | ||
return output.sort(); | ||
} | ||
_$jscoverage['license-find.js'][94]++; | ||
_$jscoverage['license-find.js'][109]++; | ||
module.exports = identifyLicense; | ||
_$jscoverage['license-find.js'].source = ["/**"," *"," * @description Module for identifying license from a text string"," * @author Ian Kelly"," *"," * @copyright Copyright (C) Ian Kelly"," *"," * @license The MIT License"," *"," * @@NLF-IGNORE@@"," * "," */","","'use strict';","","var patterns = [ {","\t\t'name': 'BSD',","\t\t'regex': [","\t\t\t/\\sBSD\\s/","\t\t]","\t},","\t{","\t\t'name': 'GPL',","\t\t'regex': [","\t\t\t/\\sGPL\\s/,","\t\t\t/\\sGPLv2\\s/","\t\t]","\t},","\t{","\t\t'name': 'LGPL',","\t\t'regex': [","\t\t\t/\\sLGPL\\s/","\t\t]","\t},","\t{","\t\t'name': 'MIT',","\t\t'regex' : [","\t\t\t/\\sMIT\\s/,","\t\t\t/\\s\\(MIT\\)\\s/","\t\t]","\t},","\t{","\t\t'name': 'Apache',","\t\t'regex': [","\t\t\t/\\sApache\\sLicen[cs]e\\s/i","\t\t]","\t},","\t{","\t\t'name': 'MPL',","\t\t'regex': [","\t\t\t/\\sMPL\\s/","\t\t]","\t},","\t{","\t\t'name': 'WTFPL',","\t\t'regex': [","\t\t\t/\\sDO\\sWHAT\\sTHE\\sFUCK\\sYOU\\sWANT\\sTO\\sPUBLIC\\sLICEN[CS]E\\s/i","\t\t]","","\t}","],","\t// pattern to deliberately exclude a file","\texcludePattern = /@@NLF-IGNORE@@/;","","/**"," * Identifies potential license text"," * "," * @param {String} text The text to scan"," * @return {Array} Array of potential license names"," */","function identifyLicense(text) {","","\tvar licenseIndex,","\t\tregexIndex,","\t\tpattern,","\t\toutput = [];","","\t// ignore files that have the ignore flag - e.g. the nfl project itself","\tif (!excludePattern.test(text)) {","\t\tfor (licenseIndex = patterns.length - 1; licenseIndex >= 0; licenseIndex--) {","\t\t\tpattern = patterns[licenseIndex];","\t\t\tfor (regexIndex = pattern.regex.length - 1; regexIndex >= 0; regexIndex--) {","\t\t\t\tif (pattern.regex[regexIndex].test(text)) {","\t\t\t\t\toutput.push(pattern.name);","\t\t\t\t\tbreak;","\t\t\t\t}","\t\t\t}","\t\t}","\t}","","\treturn output.sort();","}","","module.exports = identifyLicense;"]; | ||
_$jscoverage['license-find.js'].source = ["/**"," *"," * @description Module for identifying license from a text string"," * @author Ian Kelly"," *"," * @copyright Copyright (C) Ian Kelly"," *"," * @license The MIT License"," *"," * @@NLF-IGNORE@@"," * "," */","","'use strict';","","var patterns = [ {","\t\t'name': 'BSD',","\t\t'regex': [","\t\t\t/(?:^|\\s)BSD\\s/","\t\t]","\t},","\t{","\t\t'name': 'GPL',","\t\t'regex': [","\t\t\t/(?:^|\\s)GPL\\s/,","\t\t\t/(?:^|\\s)GPLv\\d\\s/","\t\t]","\t},","\t{","\t\t'name': 'LGPL',","\t\t'regex': [","\t\t\t/(?:^|\\s)LGPL\\s/","\t\t]","\t},","\t{","\t\t'name': 'MIT',","\t\t'regex' : [","\t\t\t/(?:^|\\s)MIT\\s/,","\t\t\t/(?:^|\\s)\\(MIT\\)\\s/","\t\t]","\t},","\t{","\t\t'name': 'Apache',","\t\t'regex': [","\t\t\t/(?:^|\\s)Apache\\sLicen[cs]e\\s/i","\t\t]","\t},","\t{","\t\t'name': 'MPL',","\t\t'regex': [","\t\t\t/(?:^|\\s)MPL\\s/","\t\t]","\t},","\t{","\t\t'name': 'WTFPL',","\t\t'regex': [","\t\t\t/(?:^|\\s)WTFPL\\s/,","\t\t\t/(?:^|\\s)DO\\sWHAT\\sTHE\\sFUCK\\sYOU\\sWANT\\sTO\\sPUBLIC\\sLICEN[CS]E\\s/i","\t\t]","\t},","\t{","\t\t'name': 'ISC',","\t\t'regex': [","\t\t\t/(?:^|\\s)ISC\\s/,","\t\t\t/(?:^|\\s)\\(ISC\\)\\s/","\t\t]","\t},","\t{","\t\t'name': 'Eclipse Public License',","\t\t'regex': [","\t\t\t/(?:^|\\s)Eclipse\\sPublic\\sLicen[cs]e\\s/i,","\t\t\t/(?:^|\\s)EPL\\s/,","\t\t\t/(?:(?:^|\\s)|\\()EPL-1\\.0(?:\\)|\\s)/","\t\t]","\t}","],","\t// pattern to deliberately exclude a file","\texcludePattern = /@@NLF-IGNORE@@/;","","/**"," * Identifies potential license text"," * "," * @param {String} text The text to scan"," * @return {Array} Array of potential license names"," */","function identifyLicense(text) {","","\tvar licenseIndex,","\t\tregexIndex,","\t\tpattern,","\t\toutput = [];","\t\t","\t// ignore files that have the ignore flag - e.g. the nfl project itself","\tif (!excludePattern.test(text)) {","\t\tfor (licenseIndex = patterns.length - 1; licenseIndex >= 0; licenseIndex--) {","\t\t\tpattern = patterns[licenseIndex];","\t\t\tfor (regexIndex = pattern.regex.length - 1; regexIndex >= 0; regexIndex--) {","\t\t\t\tif (pattern.regex[regexIndex].test(text)) {","\t\t\t\t\toutput.push(pattern.name);","\t\t\t\t\tbreak;","\t\t\t\t}","\t\t\t}","\t\t}","\t}","","\treturn output.sort();","}","","module.exports = identifyLicense;"]; |
@@ -7,110 +7,126 @@ /* automatically generated by JSCoverage - do not edit */ | ||
_$jscoverage['nlf.js'][13] = 0; | ||
_$jscoverage['nlf.js'][31] = 0; | ||
_$jscoverage['nlf.js'][34] = 0; | ||
_$jscoverage['nlf.js'][32] = 0; | ||
_$jscoverage['nlf.js'][35] = 0; | ||
_$jscoverage['nlf.js'][38] = 0; | ||
_$jscoverage['nlf.js'][43] = 0; | ||
_$jscoverage['nlf.js'][36] = 0; | ||
_$jscoverage['nlf.js'][39] = 0; | ||
_$jscoverage['nlf.js'][44] = 0; | ||
_$jscoverage['nlf.js'][45] = 0; | ||
_$jscoverage['nlf.js'][46] = 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'][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'][79] = 0; | ||
_$jscoverage['nlf.js'][84] = 0; | ||
_$jscoverage['nlf.js'][87] = 0; | ||
_$jscoverage['nlf.js'][90] = 0; | ||
_$jscoverage['nlf.js'][80] = 0; | ||
_$jscoverage['nlf.js'][85] = 0; | ||
_$jscoverage['nlf.js'][88] = 0; | ||
_$jscoverage['nlf.js'][91] = 0; | ||
_$jscoverage['nlf.js'][93] = 0; | ||
_$jscoverage['nlf.js'][95] = 0; | ||
_$jscoverage['nlf.js'][92] = 0; | ||
_$jscoverage['nlf.js'][94] = 0; | ||
_$jscoverage['nlf.js'][96] = 0; | ||
_$jscoverage['nlf.js'][100] = 0; | ||
_$jscoverage['nlf.js'][103] = 0; | ||
_$jscoverage['nlf.js'][106] = 0; | ||
_$jscoverage['nlf.js'][97] = 0; | ||
_$jscoverage['nlf.js'][101] = 0; | ||
_$jscoverage['nlf.js'][104] = 0; | ||
_$jscoverage['nlf.js'][107] = 0; | ||
_$jscoverage['nlf.js'][108] = 0; | ||
_$jscoverage['nlf.js'][111] = 0; | ||
_$jscoverage['nlf.js'][116] = 0; | ||
_$jscoverage['nlf.js'][118] = 0; | ||
_$jscoverage['nlf.js'][124] = 0; | ||
_$jscoverage['nlf.js'][109] = 0; | ||
_$jscoverage['nlf.js'][112] = 0; | ||
_$jscoverage['nlf.js'][117] = 0; | ||
_$jscoverage['nlf.js'][119] = 0; | ||
_$jscoverage['nlf.js'][125] = 0; | ||
_$jscoverage['nlf.js'][140] = 0; | ||
_$jscoverage['nlf.js'][142] = 0; | ||
_$jscoverage['nlf.js'][126] = 0; | ||
_$jscoverage['nlf.js'][141] = 0; | ||
_$jscoverage['nlf.js'][143] = 0; | ||
_$jscoverage['nlf.js'][146] = 0; | ||
_$jscoverage['nlf.js'][144] = 0; | ||
_$jscoverage['nlf.js'][147] = 0; | ||
_$jscoverage['nlf.js'][151] = 0; | ||
_$jscoverage['nlf.js'][153] = 0; | ||
_$jscoverage['nlf.js'][148] = 0; | ||
_$jscoverage['nlf.js'][152] = 0; | ||
_$jscoverage['nlf.js'][154] = 0; | ||
_$jscoverage['nlf.js'][157] = 0; | ||
_$jscoverage['nlf.js'][161] = 0; | ||
_$jscoverage['nlf.js'][155] = 0; | ||
_$jscoverage['nlf.js'][158] = 0; | ||
_$jscoverage['nlf.js'][162] = 0; | ||
_$jscoverage['nlf.js'][165] = 0; | ||
_$jscoverage['nlf.js'][163] = 0; | ||
_$jscoverage['nlf.js'][166] = 0; | ||
_$jscoverage['nlf.js'][170] = 0; | ||
_$jscoverage['nlf.js'][182] = 0; | ||
_$jscoverage['nlf.js'][185] = 0; | ||
_$jscoverage['nlf.js'][167] = 0; | ||
_$jscoverage['nlf.js'][171] = 0; | ||
_$jscoverage['nlf.js'][183] = 0; | ||
_$jscoverage['nlf.js'][186] = 0; | ||
_$jscoverage['nlf.js'][189] = 0; | ||
_$jscoverage['nlf.js'][196] = 0; | ||
_$jscoverage['nlf.js'][187] = 0; | ||
_$jscoverage['nlf.js'][190] = 0; | ||
_$jscoverage['nlf.js'][197] = 0; | ||
_$jscoverage['nlf.js'][198] = 0; | ||
_$jscoverage['nlf.js'][201] = 0; | ||
_$jscoverage['nlf.js'][199] = 0; | ||
_$jscoverage['nlf.js'][202] = 0; | ||
_$jscoverage['nlf.js'][203] = 0; | ||
_$jscoverage['nlf.js'][208] = 0; | ||
_$jscoverage['nlf.js'][204] = 0; | ||
_$jscoverage['nlf.js'][209] = 0; | ||
_$jscoverage['nlf.js'][210] = 0; | ||
_$jscoverage['nlf.js'][212] = 0; | ||
_$jscoverage['nlf.js'][222] = 0; | ||
_$jscoverage['nlf.js'][224] = 0; | ||
_$jscoverage['nlf.js'][230] = 0; | ||
_$jscoverage['nlf.js'][233] = 0; | ||
_$jscoverage['nlf.js'][211] = 0; | ||
_$jscoverage['nlf.js'][213] = 0; | ||
_$jscoverage['nlf.js'][223] = 0; | ||
_$jscoverage['nlf.js'][225] = 0; | ||
_$jscoverage['nlf.js'][231] = 0; | ||
_$jscoverage['nlf.js'][234] = 0; | ||
_$jscoverage['nlf.js'][237] = 0; | ||
_$jscoverage['nlf.js'][239] = 0; | ||
_$jscoverage['nlf.js'][235] = 0; | ||
_$jscoverage['nlf.js'][238] = 0; | ||
_$jscoverage['nlf.js'][240] = 0; | ||
_$jscoverage['nlf.js'][244] = 0; | ||
_$jscoverage['nlf.js'][247] = 0; | ||
_$jscoverage['nlf.js'][241] = 0; | ||
_$jscoverage['nlf.js'][245] = 0; | ||
_$jscoverage['nlf.js'][248] = 0; | ||
_$jscoverage['nlf.js'][251] = 0; | ||
_$jscoverage['nlf.js'][249] = 0; | ||
_$jscoverage['nlf.js'][252] = 0; | ||
_$jscoverage['nlf.js'][253] = 0; | ||
_$jscoverage['nlf.js'][254] = 0; | ||
_$jscoverage['nlf.js'][258] = 0; | ||
_$jscoverage['nlf.js'][259] = 0; | ||
_$jscoverage['nlf.js'][255] = 0; | ||
_$jscoverage['nlf.js'][256] = 0; | ||
_$jscoverage['nlf.js'][261] = 0; | ||
_$jscoverage['nlf.js'][262] = 0; | ||
_$jscoverage['nlf.js'][275] = 0; | ||
_$jscoverage['nlf.js'][277] = 0; | ||
_$jscoverage['nlf.js'][280] = 0; | ||
_$jscoverage['nlf.js'][281] = 0; | ||
_$jscoverage['nlf.js'][282] = 0; | ||
_$jscoverage['nlf.js'][286] = 0; | ||
_$jscoverage['nlf.js'][295] = 0; | ||
_$jscoverage['nlf.js'][297] = 0; | ||
_$jscoverage['nlf.js'][299] = 0; | ||
_$jscoverage['nlf.js'][300] = 0; | ||
_$jscoverage['nlf.js'][303] = 0; | ||
_$jscoverage['nlf.js'][304] = 0; | ||
_$jscoverage['nlf.js'][306] = 0; | ||
_$jscoverage['nlf.js'][266] = 0; | ||
_$jscoverage['nlf.js'][267] = 0; | ||
_$jscoverage['nlf.js'][268] = 0; | ||
_$jscoverage['nlf.js'][274] = 0; | ||
_$jscoverage['nlf.js'][287] = 0; | ||
_$jscoverage['nlf.js'][289] = 0; | ||
_$jscoverage['nlf.js'][292] = 0; | ||
_$jscoverage['nlf.js'][293] = 0; | ||
_$jscoverage['nlf.js'][294] = 0; | ||
_$jscoverage['nlf.js'][298] = 0; | ||
_$jscoverage['nlf.js'][307] = 0; | ||
_$jscoverage['nlf.js'][310] = 0; | ||
_$jscoverage['nlf.js'][309] = 0; | ||
_$jscoverage['nlf.js'][311] = 0; | ||
_$jscoverage['nlf.js'][314] = 0; | ||
_$jscoverage['nlf.js'][312] = 0; | ||
_$jscoverage['nlf.js'][315] = 0; | ||
_$jscoverage['nlf.js'][316] = 0; | ||
_$jscoverage['nlf.js'][318] = 0; | ||
_$jscoverage['nlf.js'][319] = 0; | ||
_$jscoverage['nlf.js'][322] = 0; | ||
_$jscoverage['nlf.js'][323] = 0; | ||
_$jscoverage['nlf.js'][326] = 0; | ||
_$jscoverage['nlf.js'][327] = 0; | ||
_$jscoverage['nlf.js'][329] = 0; | ||
_$jscoverage['nlf.js'][336] = 0; | ||
_$jscoverage['nlf.js'][337] = 0; | ||
_$jscoverage['nlf.js'][338] = 0; | ||
_$jscoverage['nlf.js'][339] = 0; | ||
_$jscoverage['nlf.js'][340] = 0; | ||
_$jscoverage['nlf.js'][342] = 0; | ||
_$jscoverage['nlf.js'][344] = 0; | ||
_$jscoverage['nlf.js'][343] = 0; | ||
_$jscoverage['nlf.js'][345] = 0; | ||
_$jscoverage['nlf.js'][346] = 0; | ||
_$jscoverage['nlf.js'][350] = 0; | ||
_$jscoverage['nlf.js'][352] = 0; | ||
_$jscoverage['nlf.js'][353] = 0; | ||
_$jscoverage['nlf.js'][357] = 0; | ||
_$jscoverage['nlf.js'][362] = 0; | ||
_$jscoverage['nlf.js'][355] = 0; | ||
_$jscoverage['nlf.js'][358] = 0; | ||
_$jscoverage['nlf.js'][359] = 0; | ||
_$jscoverage['nlf.js'][360] = 0; | ||
_$jscoverage['nlf.js'][363] = 0; | ||
_$jscoverage['nlf.js'][364] = 0; | ||
_$jscoverage['nlf.js'][366] = 0; | ||
_$jscoverage['nlf.js'][374] = 0; | ||
_$jscoverage['nlf.js'][375] = 0; | ||
_$jscoverage['nlf.js'][379] = 0; | ||
_$jscoverage['nlf.js'][380] = 0; | ||
_$jscoverage['nlf.js'][384] = 0; | ||
_$jscoverage['nlf.js'][386] = 0; | ||
_$jscoverage['nlf.js'][387] = 0; | ||
_$jscoverage['nlf.js'][388] = 0; | ||
_$jscoverage['nlf.js'][392] = 0; | ||
_$jscoverage['nlf.js'][394] = 0; | ||
_$jscoverage['nlf.js'][395] = 0; | ||
_$jscoverage['nlf.js'][399] = 0; | ||
_$jscoverage['nlf.js'][404] = 0; | ||
} | ||
@@ -120,19 +136,19 @@ _$jscoverage['nlf.js'][11]++; | ||
_$jscoverage['nlf.js'][13]++; | ||
var readInstalled = require("read-installed"), Module = require("./module"), path = require("path"), 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'][31]++; | ||
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]++; | ||
function isDevDependency(moduleData) { | ||
_$jscoverage['nlf.js'][34]++; | ||
_$jscoverage['nlf.js'][35]++; | ||
if (moduleData.parent === undefined) { | ||
_$jscoverage['nlf.js'][35]++; | ||
_$jscoverage['nlf.js'][36]++; | ||
return false; | ||
} | ||
_$jscoverage['nlf.js'][38]++; | ||
_$jscoverage['nlf.js'][39]++; | ||
var dependencies = moduleData.parent.devDependencies || {}, dependencyName; | ||
_$jscoverage['nlf.js'][43]++; | ||
_$jscoverage['nlf.js'][44]++; | ||
for (dependencyName in dependencies) { | ||
_$jscoverage['nlf.js'][44]++; | ||
_$jscoverage['nlf.js'][45]++; | ||
if (dependencies.hasOwnProperty(dependencyName)) { | ||
_$jscoverage['nlf.js'][45]++; | ||
_$jscoverage['nlf.js'][46]++; | ||
if (dependencyName === moduleData.name) { | ||
_$jscoverage['nlf.js'][46]++; | ||
_$jscoverage['nlf.js'][47]++; | ||
return true; | ||
@@ -142,48 +158,48 @@ } | ||
} | ||
_$jscoverage['nlf.js'][51]++; | ||
_$jscoverage['nlf.js'][52]++; | ||
return false; | ||
} | ||
_$jscoverage['nlf.js'][62]++; | ||
_$jscoverage['nlf.js'][63]++; | ||
function parseInstalled(data, options, callback) { | ||
_$jscoverage['nlf.js'][65]++; | ||
_$jscoverage['nlf.js'][66]++; | ||
var count = 0; | ||
_$jscoverage['nlf.js'][74]++; | ||
_$jscoverage['nlf.js'][75]++; | ||
(function parseModuleData(moduleData, output) { | ||
_$jscoverage['nlf.js'][78]++; | ||
_$jscoverage['nlf.js'][79]++; | ||
if (options.production && isDevDependency(moduleData)) { | ||
_$jscoverage['nlf.js'][79]++; | ||
_$jscoverage['nlf.js'][80]++; | ||
return; | ||
} | ||
_$jscoverage['nlf.js'][84]++; | ||
_$jscoverage['nlf.js'][85]++; | ||
if (! output.hasOwnProperty(moduleData._id)) { | ||
_$jscoverage['nlf.js'][87]++; | ||
_$jscoverage['nlf.js'][88]++; | ||
output[moduleData._id] = null; | ||
_$jscoverage['nlf.js'][90]++; | ||
_$jscoverage['nlf.js'][91]++; | ||
count++; | ||
_$jscoverage['nlf.js'][91]++; | ||
_$jscoverage['nlf.js'][92]++; | ||
createModule(moduleData, (function (err, module) { | ||
_$jscoverage['nlf.js'][93]++; | ||
_$jscoverage['nlf.js'][94]++; | ||
count--; | ||
_$jscoverage['nlf.js'][95]++; | ||
_$jscoverage['nlf.js'][96]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][96]++; | ||
_$jscoverage['nlf.js'][97]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][100]++; | ||
_$jscoverage['nlf.js'][101]++; | ||
output[moduleData._id] = module; | ||
_$jscoverage['nlf.js'][103]++; | ||
_$jscoverage['nlf.js'][104]++; | ||
var dependencies = moduleData.dependencies || {}, name; | ||
_$jscoverage['nlf.js'][106]++; | ||
_$jscoverage['nlf.js'][107]++; | ||
for (name in dependencies) { | ||
_$jscoverage['nlf.js'][107]++; | ||
_$jscoverage['nlf.js'][108]++; | ||
if (dependencies.hasOwnProperty(name)) { | ||
_$jscoverage['nlf.js'][108]++; | ||
_$jscoverage['nlf.js'][109]++; | ||
if (typeof dependencies[name] === "object") { | ||
_$jscoverage['nlf.js'][111]++; | ||
_$jscoverage['nlf.js'][112]++; | ||
parseModuleData(dependencies[name], output); | ||
} | ||
else { | ||
_$jscoverage['nlf.js'][116]++; | ||
_$jscoverage['nlf.js'][117]++; | ||
console.warn("Warning: dependency \"" + name + "\" probably not installed."); | ||
_$jscoverage['nlf.js'][118]++; | ||
_$jscoverage['nlf.js'][119]++; | ||
console.warn("please install dependencies from npm before running nlf"); | ||
@@ -193,5 +209,5 @@ } | ||
} | ||
_$jscoverage['nlf.js'][124]++; | ||
_$jscoverage['nlf.js'][125]++; | ||
if (count === 0) { | ||
_$jscoverage['nlf.js'][125]++; | ||
_$jscoverage['nlf.js'][126]++; | ||
callback(null, output); | ||
@@ -203,109 +219,119 @@ } | ||
} | ||
_$jscoverage['nlf.js'][140]++; | ||
_$jscoverage['nlf.js'][141]++; | ||
function findPotentialLicenseFiles(directory, pattern, callback) { | ||
_$jscoverage['nlf.js'][142]++; | ||
_$jscoverage['nlf.js'][143]++; | ||
if (typeof pattern !== "string") { | ||
_$jscoverage['nlf.js'][143]++; | ||
_$jscoverage['nlf.js'][144]++; | ||
return callback(new Error("pattern must be a string")); | ||
} | ||
_$jscoverage['nlf.js'][146]++; | ||
_$jscoverage['nlf.js'][147]++; | ||
if (typeof directory !== "string") { | ||
_$jscoverage['nlf.js'][147]++; | ||
_$jscoverage['nlf.js'][148]++; | ||
return callback(new Error("directory must be a string")); | ||
} | ||
_$jscoverage['nlf.js'][151]++; | ||
_$jscoverage['nlf.js'][152]++; | ||
glob(pattern, {nocase: true, cwd: directory}, (function (err, files) { | ||
_$jscoverage['nlf.js'][153]++; | ||
_$jscoverage['nlf.js'][154]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][154]++; | ||
_$jscoverage['nlf.js'][155]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][157]++; | ||
_$jscoverage['nlf.js'][158]++; | ||
var fileIndex, matchedFile, found = []; | ||
_$jscoverage['nlf.js'][161]++; | ||
_$jscoverage['nlf.js'][162]++; | ||
for (fileIndex = files.length - 1; fileIndex >= 0; fileIndex--) { | ||
_$jscoverage['nlf.js'][162]++; | ||
_$jscoverage['nlf.js'][163]++; | ||
matchedFile = files[fileIndex]; | ||
_$jscoverage['nlf.js'][165]++; | ||
_$jscoverage['nlf.js'][166]++; | ||
if (! matchNodeModules.test(matchedFile)) { | ||
_$jscoverage['nlf.js'][166]++; | ||
_$jscoverage['nlf.js'][167]++; | ||
found.push(path.join(directory, matchedFile)); | ||
} | ||
} | ||
_$jscoverage['nlf.js'][170]++; | ||
_$jscoverage['nlf.js'][171]++; | ||
callback(null, found); | ||
})); | ||
} | ||
_$jscoverage['nlf.js'][182]++; | ||
_$jscoverage['nlf.js'][183]++; | ||
function addFiles(filePaths, collection, callback) { | ||
_$jscoverage['nlf.js'][185]++; | ||
_$jscoverage['nlf.js'][186]++; | ||
if (! filePaths || filePaths.length === 0) { | ||
_$jscoverage['nlf.js'][186]++; | ||
_$jscoverage['nlf.js'][187]++; | ||
return callback(null); | ||
} | ||
_$jscoverage['nlf.js'][189]++; | ||
_$jscoverage['nlf.js'][190]++; | ||
var fileIndex, pending = filePaths.length, source; | ||
_$jscoverage['nlf.js'][196]++; | ||
_$jscoverage['nlf.js'][197]++; | ||
function checkDone(err) { | ||
_$jscoverage['nlf.js'][197]++; | ||
_$jscoverage['nlf.js'][198]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][198]++; | ||
_$jscoverage['nlf.js'][199]++; | ||
callback(err); | ||
} | ||
_$jscoverage['nlf.js'][201]++; | ||
_$jscoverage['nlf.js'][202]++; | ||
pending--; | ||
_$jscoverage['nlf.js'][202]++; | ||
_$jscoverage['nlf.js'][203]++; | ||
if (! pending) { | ||
_$jscoverage['nlf.js'][203]++; | ||
_$jscoverage['nlf.js'][204]++; | ||
callback(null); | ||
} | ||
} | ||
_$jscoverage['nlf.js'][208]++; | ||
_$jscoverage['nlf.js'][209]++; | ||
for (fileIndex = 0; fileIndex < filePaths.length; fileIndex++) { | ||
_$jscoverage['nlf.js'][209]++; | ||
_$jscoverage['nlf.js'][210]++; | ||
source = new FileSource(filePaths[fileIndex]); | ||
_$jscoverage['nlf.js'][210]++; | ||
_$jscoverage['nlf.js'][211]++; | ||
collection.add(source); | ||
_$jscoverage['nlf.js'][212]++; | ||
_$jscoverage['nlf.js'][213]++; | ||
source.read(checkDone); | ||
} | ||
} | ||
_$jscoverage['nlf.js'][222]++; | ||
_$jscoverage['nlf.js'][223]++; | ||
function createModule(moduleData, callback) { | ||
_$jscoverage['nlf.js'][224]++; | ||
_$jscoverage['nlf.js'][225]++; | ||
var repository = (moduleData.repository || {}).url || "(none)", directory = moduleData.path, module = new Module(moduleData._id, moduleData.name, moduleData.version, directory, repository); | ||
_$jscoverage['nlf.js'][230]++; | ||
_$jscoverage['nlf.js'][231]++; | ||
findPotentialLicenseFiles(directory, "**/*license*", (function (err, licenseFiles) { | ||
_$jscoverage['nlf.js'][233]++; | ||
_$jscoverage['nlf.js'][234]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][234]++; | ||
_$jscoverage['nlf.js'][235]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][237]++; | ||
_$jscoverage['nlf.js'][238]++; | ||
addFiles(licenseFiles, module.licenseSources.license, (function (err) { | ||
_$jscoverage['nlf.js'][239]++; | ||
_$jscoverage['nlf.js'][240]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][240]++; | ||
_$jscoverage['nlf.js'][241]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][244]++; | ||
_$jscoverage['nlf.js'][245]++; | ||
findPotentialLicenseFiles(directory, "**/*readme*", (function (err, readmeFiles) { | ||
_$jscoverage['nlf.js'][247]++; | ||
_$jscoverage['nlf.js'][248]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][248]++; | ||
_$jscoverage['nlf.js'][249]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][251]++; | ||
_$jscoverage['nlf.js'][252]++; | ||
addFiles(readmeFiles, module.licenseSources.readme, (function (err) { | ||
_$jscoverage['nlf.js'][253]++; | ||
var index; | ||
_$jscoverage['nlf.js'][255]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][254]++; | ||
_$jscoverage['nlf.js'][256]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][258]++; | ||
_$jscoverage['nlf.js'][261]++; | ||
if (moduleData.license) { | ||
_$jscoverage['nlf.js'][259]++; | ||
_$jscoverage['nlf.js'][262]++; | ||
module.licenseSources["package"].add(new PackageSource(moduleData.license)); | ||
} | ||
_$jscoverage['nlf.js'][262]++; | ||
_$jscoverage['nlf.js'][266]++; | ||
if (moduleData.licenses) { | ||
_$jscoverage['nlf.js'][267]++; | ||
for (index = 0; index < moduleData.licenses.length; index++) { | ||
_$jscoverage['nlf.js'][268]++; | ||
module.licenseSources["package"].add(new PackageSource(moduleData.licenses[index])); | ||
} | ||
} | ||
_$jscoverage['nlf.js'][274]++; | ||
callback(null, module); | ||
@@ -317,74 +343,107 @@ })); | ||
} | ||
_$jscoverage['nlf.js'][275]++; | ||
_$jscoverage['nlf.js'][287]++; | ||
function convertToArray(object) { | ||
_$jscoverage['nlf.js'][277]++; | ||
_$jscoverage['nlf.js'][289]++; | ||
var propertyName, output = []; | ||
_$jscoverage['nlf.js'][280]++; | ||
_$jscoverage['nlf.js'][292]++; | ||
for (propertyName in object) { | ||
_$jscoverage['nlf.js'][281]++; | ||
_$jscoverage['nlf.js'][293]++; | ||
if (object.hasOwnProperty(propertyName)) { | ||
_$jscoverage['nlf.js'][282]++; | ||
_$jscoverage['nlf.js'][294]++; | ||
output.push(object[propertyName]); | ||
} | ||
} | ||
_$jscoverage['nlf.js'][286]++; | ||
_$jscoverage['nlf.js'][298]++; | ||
return output; | ||
} | ||
_$jscoverage['nlf.js'][295]++; | ||
_$jscoverage['nlf.js'][307]++; | ||
function processOptions(options) { | ||
_$jscoverage['nlf.js'][297]++; | ||
_$jscoverage['nlf.js'][309]++; | ||
options = options || {}; | ||
_$jscoverage['nlf.js'][299]++; | ||
_$jscoverage['nlf.js'][311]++; | ||
if (typeof options !== "object") { | ||
_$jscoverage['nlf.js'][300]++; | ||
_$jscoverage['nlf.js'][312]++; | ||
throw new Error("options must be an object"); | ||
} | ||
_$jscoverage['nlf.js'][303]++; | ||
_$jscoverage['nlf.js'][315]++; | ||
options.directory = options.directory || process.cwd(); | ||
_$jscoverage['nlf.js'][304]++; | ||
_$jscoverage['nlf.js'][316]++; | ||
options.production = options.production || false; | ||
_$jscoverage['nlf.js'][306]++; | ||
_$jscoverage['nlf.js'][318]++; | ||
if (typeof options.directory !== "string") { | ||
_$jscoverage['nlf.js'][307]++; | ||
_$jscoverage['nlf.js'][319]++; | ||
throw new Error("options.directory must be a string"); | ||
} | ||
_$jscoverage['nlf.js'][310]++; | ||
_$jscoverage['nlf.js'][322]++; | ||
if (typeof options.production !== "boolean") { | ||
_$jscoverage['nlf.js'][311]++; | ||
_$jscoverage['nlf.js'][323]++; | ||
throw new Error("options.production must be a boolean"); | ||
} | ||
_$jscoverage['nlf.js'][314]++; | ||
_$jscoverage['nlf.js'][326]++; | ||
return options; | ||
} | ||
_$jscoverage['nlf.js'][323]++; | ||
_$jscoverage['nlf.js'][336]++; | ||
function fileExistsSync(filePath) { | ||
_$jscoverage['nlf.js'][338]++; | ||
try { | ||
_$jscoverage['nlf.js'][339]++; | ||
var stats = fs.statSync(filePath); | ||
_$jscoverage['nlf.js'][340]++; | ||
return stats.isFile(); | ||
} | ||
catch (err) { | ||
_$jscoverage['nlf.js'][342]++; | ||
if (err.code === "ENOENT") { | ||
_$jscoverage['nlf.js'][343]++; | ||
return false; | ||
} | ||
_$jscoverage['nlf.js'][345]++; | ||
throw err; | ||
} | ||
} | ||
_$jscoverage['nlf.js'][355]++; | ||
function find(options, callback) { | ||
_$jscoverage['nlf.js'][326]++; | ||
if (typeof options === "function" && typeof callback === undefined) { | ||
_$jscoverage['nlf.js'][327]++; | ||
_$jscoverage['nlf.js'][358]++; | ||
if (typeof options === "function" && callback === undefined) { | ||
_$jscoverage['nlf.js'][359]++; | ||
callback = options; | ||
_$jscoverage['nlf.js'][360]++; | ||
options = undefined; | ||
} | ||
_$jscoverage['nlf.js'][329]++; | ||
options = processOptions(options); | ||
_$jscoverage['nlf.js'][336]++; | ||
_$jscoverage['nlf.js'][363]++; | ||
try { | ||
_$jscoverage['nlf.js'][364]++; | ||
options = processOptions(options); | ||
} | ||
catch (err) { | ||
_$jscoverage['nlf.js'][366]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][374]++; | ||
function log(output) { | ||
_$jscoverage['nlf.js'][337]++; | ||
_$jscoverage['nlf.js'][375]++; | ||
console.error("Error in reading node_module dependencies, error was: " + output); | ||
} | ||
_$jscoverage['nlf.js'][342]++; | ||
_$jscoverage['nlf.js'][379]++; | ||
if (! fileExistsSync(path.join(options.directory, "package.json"))) { | ||
_$jscoverage['nlf.js'][380]++; | ||
return callback(new Error("No package.json file found.")); | ||
} | ||
_$jscoverage['nlf.js'][384]++; | ||
readInstalled(options.directory, null, log, (function (err, data) { | ||
_$jscoverage['nlf.js'][344]++; | ||
_$jscoverage['nlf.js'][386]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][345]++; | ||
_$jscoverage['nlf.js'][387]++; | ||
console.error("Serious problem reading node_module dependencies"); | ||
_$jscoverage['nlf.js'][346]++; | ||
_$jscoverage['nlf.js'][388]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][350]++; | ||
_$jscoverage['nlf.js'][392]++; | ||
parseInstalled(data, options, (function (err, output) { | ||
_$jscoverage['nlf.js'][352]++; | ||
_$jscoverage['nlf.js'][394]++; | ||
if (err) { | ||
_$jscoverage['nlf.js'][353]++; | ||
_$jscoverage['nlf.js'][395]++; | ||
return callback(err); | ||
} | ||
_$jscoverage['nlf.js'][357]++; | ||
_$jscoverage['nlf.js'][399]++; | ||
callback(null, convertToArray(output)); | ||
@@ -394,4 +453,4 @@ })); | ||
} | ||
_$jscoverage['nlf.js'][362]++; | ||
_$jscoverage['nlf.js'][404]++; | ||
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'),","\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 && 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 >= 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\tfound.push(path.join(directory, matchedFile));","\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 < 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\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\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\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;","}","","/**"," * 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' && typeof callback === undefined) {","\t\tcallback = options;","\t}","\toptions = processOptions(options);","","\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}","","\t// use npm read-installed module to search out all the node modules","\treadInstalled(options.directory, null, 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'),","\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 && 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 >= 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\tfound.push(path.join(directory, matchedFile));","\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 < 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 < 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' && 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, null, 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","};"]; |
@@ -19,3 +19,3 @@ /** | ||
* @param {String} filePath Path of the file | ||
* @returns {Object} The FileSource object | ||
* @returns {Object} The FileSource object | ||
*/ | ||
@@ -22,0 +22,0 @@ function FileSource(filePath) { |
@@ -43,2 +43,6 @@ /** | ||
if (typeof callback !== 'function') { | ||
throw new Error('must have a callback'); | ||
} | ||
if (!Array.isArray(licenseData)) { | ||
@@ -52,6 +56,2 @@ return callback(new Error('licenseData must be an array')); | ||
if (typeof callback !== 'function') { | ||
return callback(new Error('must have a callback')); | ||
} | ||
var output = []; | ||
@@ -58,0 +58,0 @@ |
@@ -57,2 +57,6 @@ /** | ||
if (typeof callback !== 'function') { | ||
throw new Error('must have a callback'); | ||
} | ||
if (!Array.isArray(licenseData)) { | ||
@@ -66,6 +70,2 @@ return callback(new Error('licenseData must be an array')); | ||
if (typeof callback !== 'function') { | ||
return callback(new Error('must have a callback')); | ||
} | ||
var output = []; | ||
@@ -72,0 +72,0 @@ |
@@ -26,3 +26,3 @@ /** | ||
/(?:^|\s)GPL\s/, | ||
/(?:^|\s)GPLv2\s/ | ||
/(?:^|\s)GPLv\d\s/ | ||
] | ||
@@ -58,5 +58,5 @@ }, | ||
'regex': [ | ||
/(?:^|\s)WTFPL\s/, | ||
/(?:^|\s)DO\sWHAT\sTHE\sFUCK\sYOU\sWANT\sTO\sPUBLIC\sLICEN[CS]E\s/i | ||
] | ||
}, | ||
@@ -69,2 +69,10 @@ { | ||
] | ||
}, | ||
{ | ||
'name': 'Eclipse Public License', | ||
'regex': [ | ||
/(?:^|\s)Eclipse\sPublic\sLicen[cs]e\s/i, | ||
/(?:^|\s)EPL\s/, | ||
/(?:(?:^|\s)|\()EPL-1\.0(?:\)|\s)/ | ||
] | ||
} | ||
@@ -87,3 +95,3 @@ ], | ||
output = []; | ||
// ignore files that have the ignore flag - e.g. the nfl project itself | ||
@@ -90,0 +98,0 @@ if (!excludePattern.test(text)) { |
@@ -358,7 +358,13 @@ /** | ||
// process arguments | ||
if (typeof options === 'function' && typeof callback === undefined) { | ||
if (typeof options === 'function' && callback === undefined) { | ||
callback = options; | ||
options = undefined; | ||
} | ||
options = processOptions(options); | ||
try { | ||
options = processOptions(options); | ||
} catch (err) { | ||
return callback(err); | ||
} | ||
/** | ||
@@ -365,0 +371,0 @@ * Function called when readInstalled hits an issue |
@@ -6,3 +6,3 @@ { | ||
"author": "Ian Kelly <iandotkelly@gmail.com>", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"license": "MIT", | ||
@@ -25,4 +25,4 @@ "bin" : { | ||
"jshint": "~2.1.10", | ||
"should": "~1.2.2", | ||
"mocha": "~1.12.1", | ||
"should": "~1.3.0", | ||
"mocha": "~1.13.0", | ||
"globs": "~0.1.1" | ||
@@ -29,0 +29,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1869
206945
25
5