require-traverser
Advanced tools
Comparing version 0.1.8 to 0.1.9
{"name":"require-traverser", | ||
"version":"0.1.8", | ||
"version":"0.1.9", | ||
"main": "requireTraverser.js", | ||
@@ -12,3 +12,3 @@ "description": "A library for finding all the nested dependencies of a commonJS/node.js module. Uses 'detective' to traverse files.", | ||
"devDependencies": { | ||
"deadunit": "1.0.7" | ||
"deadunit": "5.2.1" | ||
}, | ||
@@ -15,0 +15,0 @@ "repository": { |
@@ -65,4 +65,8 @@ /* Copyright (c) 2013 Billy Tetrud - Free to use for any purpose: MIT License */ | ||
var traverse = function(dependencies, dependencyMap, opts) { | ||
var mainFutures = [] | ||
var mainFutures = []; | ||
dependencies.forEach(function(dependencyFile) { | ||
if (!dependencyFile.endsWith(".js")) { | ||
// only traverse js files | ||
return; | ||
} | ||
if(dependencyMap[dependencyFile] === undefined) { // only traverse a file if it hasn't already been traversed | ||
@@ -69,0 +73,0 @@ var filePath = path.resolve(dependencyFile) |
@@ -12,2 +12,7 @@ "use strict"; | ||
//* | ||
this.test("unfound dependency", function() { | ||
@@ -55,2 +60,25 @@ var t = this | ||
this.test("module with json files", function(t) { | ||
this.count(7) | ||
tr(__dirname, './testFiles/inner/fileWithJsonRequirements.js', function(e, files) { | ||
try { | ||
t.eq(e, undefined) | ||
// t.log(files) | ||
var keys = Object.keys(files) | ||
t.eq(keys.length, 2) | ||
var dependencies = files[keys[0]] | ||
t.eq(dependencies.unfound.length, 0) | ||
t.eq(dependencies.unresolved.length, 0) | ||
t.eq(dependencies.resolved.length, 2) | ||
t.eq(dependencies.resolved[0].relative, './testJson.json') | ||
t.eq(dependencies.resolved[1].relative, './dependencyA') | ||
} catch(e) { | ||
t.ok(false, e) | ||
} | ||
}) | ||
}) | ||
function isFile(filepath, errback) { | ||
@@ -199,2 +227,3 @@ var analyzeThisPath = path.resolve('testFiles/inner/analyzeThis.js') | ||
//*/ | ||
}) | ||
@@ -201,0 +230,0 @@ |
18501
23
337