1 | Returns a list of candidate root files for CommonJS or AMD JavaScript applications within a directory.
|
2 |
|
3 | A root/entry-point file is one that has dependencies but is not depended on (i.e., no other file requires it).
|
4 |
|
5 | `npm install app-root`
|
6 |
|
7 | *This is useful for automatically deducing the entry point for r.js or browserify configurations.*
|
8 |
|
9 | ```javascript
|
10 | var getAppRoot = require('app-root');
|
11 |
|
12 | // Find the application roots within the js folder
|
13 | getAppRoot('./js', function (roots) {
|
14 | ...
|
15 | })
|
16 | ```
|
17 |
|
18 | ### Ignoring particular subdirectories
|
19 |
|
20 | Supply an options object as the second parameter with a field `ignore`
|
21 | that contains a list of the directories that you want to ignore
|
22 | when looking for candidate app roots.
|
23 |
|
24 | *Otherwise, you'd end up with junk roots for 3rd party libraries/dependencies.*
|
25 |
|
26 | ```javascript
|
27 | var options = {
|
28 | ignore: ['bower_components', 'vendor', 'node_modules', '.git']
|
29 | };
|
30 |
|
31 | getAppRoot('./js', options, function (roots) {
|
32 | ...
|
33 | })
|
34 | ``` |
\ | No newline at end of file |