Skip to content
This repository
Browse code

a readme and example all up in this

  • Loading branch information...
commit bf1f2d07af94c128a89a47db1a62dcee79dd109f 1 parent b0e8032
James Halliday authored
59 README.markdown
Source Rendered
... ... @@ -0,0 +1,59 @@
  1 +detective
  2 +=========
  3 +
  4 +Find all calls to require() no matter how crazily nested using a proper walk of
  5 +the AST.
  6 +
  7 +example
  8 +=======
  9 +
  10 +strings
  11 +-------
  12 +
  13 +strings_src.js:
  14 +
  15 +````javascript
  16 +var a = require('a');
  17 +var b = require('b');
  18 +var c = require('c');
  19 +````
  20 +
  21 +strings.js:
  22 +
  23 +````javascript
  24 +var detective = require('../');
  25 +var fs = require('fs');
  26 +
  27 +var src = fs.readFileSync(__dirname + '/strings_src.js');
  28 +var requires = detective(src);
  29 +console.dir(requires);
  30 +````
  31 +
  32 +output:
  33 +
  34 + $ node examples/strings.js
  35 + [ 'a', 'b', 'c' ]
  36 +
  37 +methods
  38 +=======
  39 +
  40 +var detective = require('detective');
  41 +
  42 +detective(src)
  43 +--------------
  44 +
  45 +Give some source body `src`, return an array of all the require()s with string
  46 +arguments.
  47 +
  48 +detective.find(src)
  49 +-------------------
  50 +
  51 +Give some source body `src`, return an object with "strings" and "expressions"
  52 +arrays for each of the require() calls.
  53 +
  54 +The "expressions" array will contain the stringified expressions.
  55 +
  56 +installation
  57 +============
  58 +
  59 + npm install detective
6 example/strings.js
... ... @@ -0,0 +1,6 @@
  1 +var detective = require('../');
  2 +var fs = require('fs');
  3 +
  4 +var src = fs.readFileSync(__dirname + '/strings_src.js');
  5 +var requires = detective(src);
  6 +console.dir(requires);
3  example/strings_src.js
... ... @@ -0,0 +1,3 @@
  1 +var a = require('a');
  2 +var b = require('b');
  3 +var c = require('c');

0 comments on commit bf1f2d0

Please sign in to comment.
Something went wrong with that request. Please try again.