require-traverser
Advanced tools
Comparing version 0.1.5 to 0.1.6
{"name":"require-traverser", | ||
"version":"0.1.5", | ||
"version":"0.1.6", | ||
"main": "requireTraverser.js", | ||
@@ -4,0 +4,0 @@ "description": "A library for finding all the nested dependencies of a commonJS/node.js module. Uses 'detective' to traverse files.", |
@@ -0,1 +1,3 @@ | ||
**Status**: API finalized, needs testing | ||
requireTraverser | ||
@@ -15,3 +17,3 @@ ============= | ||
===== | ||
``` | ||
```javascript | ||
var rt = require('require-traverser') | ||
@@ -30,3 +32,3 @@ ``` | ||
* `<moduleList>` is an array of objects like: {dir: <directory>, module: <module>} | ||
* `<errback>` is a standard node.js errback | ||
* `<errback>` is a standard node.js errback (where the first parameter is the error, undefined if there was none, and the second parameter is the return value) | ||
* `<opts>` is optional, and can have any of the parameters: | ||
@@ -48,4 +50,30 @@ * isFile - function to asynchronously test whether a file exists. Takes the same parameters as fs.isFile. | ||
How to Contribute! | ||
============ | ||
Anything helps: | ||
* Creating issues (aka tickets/bugs/etc). Please feel free to use issues to report bugs, request features, and discuss changes | ||
* Updating the documentation: ie this readme file. Be bold! Help create amazing documentation! | ||
* Submitting pull requests. | ||
How to submit pull requests: | ||
1. Please create an issue and get my input before spending too much time creating a feature. Work with me to ensure your feature or addition is optimal and fits with the purpose of the project. | ||
2. Fork the repository | ||
3. clone your forked repo onto your machine and run `npm install` at its root | ||
4. If you're gonna work on multiple separate things, its best to create a separate branch for each of them | ||
5. edit! | ||
6. If it's a code change, please add to the unit tests (at test/requireTraverserTest.js) to verify that your change | ||
7. When you're done, run the unit tests and ensure they all pass | ||
8. Commit and push your changes | ||
9. Submit a pull request: https://help.github.com/articles/creating-a-pull-request | ||
Change Log | ||
========== | ||
* 0.1.6 - fixed a bug in error handling when initial modules can't be found | ||
License | ||
======= | ||
Released under the MIT license: http://opensource.org/licenses/MIT | ||
Released under the MIT license: http://opensource.org/licenses/MIT |
@@ -1,7 +0,4 @@ | ||
/* Copyright (c) 2013 Billy Tetrud - Free to use for any purpose: MIT License*/ | ||
/* Copyright (c) 2013 Billy Tetrud - Free to use for any purpose: MIT License */ | ||
'use strict'; | ||
// todo: | ||
// * implement true asynchronous version | ||
var fs = require('fs') | ||
@@ -39,8 +36,15 @@ var path = require('path') | ||
Future.all(modulesToTraverse).then(function(module) { | ||
if(module === undefined) | ||
throw Error("Couldn't find module: "+module) | ||
Future.all(modulesToTraverse).then(function(modules) { | ||
var undefinedModules = [] | ||
modules.forEach(function(module, n) { | ||
if(module === undefined) | ||
undefinedModules.push(dependencies[n].module) | ||
}) | ||
if(undefinedModules.length > 0) | ||
throw Error("Can't find modules: "+undefinedModules) | ||
var dependencyMap = {} | ||
return traverse(module, dependencyMap, opts) | ||
return traverse(modules, dependencyMap, opts) | ||
@@ -47,0 +51,0 @@ }).then(function(dependencyMap) { |
@@ -12,2 +12,12 @@ "use strict"; | ||
this.test("unfound dependency", function() { | ||
var t = this | ||
var f = new Future | ||
//futures.push(f) | ||
tr(__dirname, 'nonexistant', function(e,files) { | ||
f.return() | ||
t.ok(e.message === "Can't find modules: nonexistant", e.message) | ||
}); | ||
}) | ||
this.test("one module", function() { | ||
@@ -18,4 +28,4 @@ var t = this | ||
tr(__dirname, './testFiles/inner/analyzeThis.js', function(e,files) { | ||
console.dir(files) | ||
console.dir(e) | ||
//console.dir(files) | ||
//console.dir(e) | ||
testCallback(t, e,files) | ||
@@ -22,0 +32,0 @@ f.return() |
15172
277
77