Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

a readme and example all up in this

  • Loading branch information...
commit bf1f2d07af94c128a89a47db1a62dcee79dd109f 1 parent b0e8032
@substack authored
Showing with 68 additions and 0 deletions.
  1. +59 −0 README.markdown
  2. +6 −0 example/strings.js
  3. +3 −0  example/strings_src.js
View
59 README.markdown
@@ -0,0 +1,59 @@
+detective
+=========
+
+Find all calls to require() no matter how crazily nested using a proper walk of
+the AST.
+
+example
+=======
+
+strings
+-------
+
+strings_src.js:
+
+````javascript
+var a = require('a');
+var b = require('b');
+var c = require('c');
+````
+
+strings.js:
+
+````javascript
+var detective = require('../');
+var fs = require('fs');
+
+var src = fs.readFileSync(__dirname + '/strings_src.js');
+var requires = detective(src);
+console.dir(requires);
+````
+
+output:
+
+ $ node examples/strings.js
+ [ 'a', 'b', 'c' ]
+
+methods
+=======
+
+var detective = require('detective');
+
+detective(src)
+--------------
+
+Give some source body `src`, return an array of all the require()s with string
+arguments.
+
+detective.find(src)
+-------------------
+
+Give some source body `src`, return an object with "strings" and "expressions"
+arrays for each of the require() calls.
+
+The "expressions" array will contain the stringified expressions.
+
+installation
+============
+
+ npm install detective
View
6 example/strings.js
@@ -0,0 +1,6 @@
+var detective = require('../');
+var fs = require('fs');
+
+var src = fs.readFileSync(__dirname + '/strings_src.js');
+var requires = detective(src);
+console.dir(requires);
View
3  example/strings_src.js
@@ -0,0 +1,3 @@
+var a = require('a');
+var b = require('b');
+var c = require('c');
Please sign in to comment.
Something went wrong with that request. Please try again.