1 | findout
|
2 | ==========
|
3 |
|
4 |
|
5 | This file is generated by ape-tmpl. Do not update manually.
|
6 | --->
|
7 |
|
8 |
|
9 | <a name="badges"></a>
|
10 |
|
11 | [![Build Status][bd_travis_shield_url]][bd_travis_url]
|
12 | [![Code Climate][bd_codeclimate_shield_url]][bd_codeclimate_url]
|
13 | [![Code Coverage][bd_codeclimate_coverage_shield_url]][bd_codeclimate_url]
|
14 | [![npm Version][bd_npm_shield_url]][bd_npm_url]
|
15 | [![JS Standard][bd_standard_shield_url]][bd_standard_url]
|
16 |
|
17 | [bd_repo_url]: https://github.com/okunishinishi/node-findout
|
18 | [bd_travis_url]: http://travis-ci.org/okunishinishi/node-findout
|
19 | [bd_travis_shield_url]: http://img.shields.io/travis/okunishinishi/node-findout.svg?style=flat
|
20 | [bd_license_url]: https://github.com/okunishinishi/node-findout/blob/master/LICENSE
|
21 | [bd_codeclimate_url]: http://codeclimate.com/github/okunishinishi/node-findout
|
22 | [bd_codeclimate_shield_url]: http://img.shields.io/codeclimate/github/okunishinishi/node-findout.svg?style=flat
|
23 | [bd_codeclimate_coverage_shield_url]: http://img.shields.io/codeclimate/coverage/github/okunishinishi/node-findout.svg?style=flat
|
24 | [bd_gemnasium_url]: https://gemnasium.com/okunishinishi/node-findout
|
25 | [bd_gemnasium_shield_url]: https://gemnasium.com/okunishinishi/node-findout.svg
|
26 | [bd_npm_url]: http://www.npmjs.org/package/findout
|
27 | [bd_npm_shield_url]: http://img.shields.io/npm/v/findout.svg?style=flat
|
28 | [bd_standard_url]: http://standardjs.com/
|
29 | [bd_standard_shield_url]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | <a name="description"></a>
|
36 |
|
37 | Find out a module.
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | <a name="sections"></a>
|
46 |
|
47 |
|
48 |
|
49 | <a name="section-doc-readme-01-installation-md"></a>
|
50 | Installation
|
51 | -----
|
52 |
|
53 | ```bash
|
54 | npm install findout --save
|
55 | ```
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | <a name="section-doc-readme-02-usage-md"></a>
|
63 | Usage
|
64 | ----
|
65 |
|
66 | `findout(name)` works like `require()`, but has a lot more locations to search.
|
67 |
|
68 |
|
69 | ```javascript
|
70 | 'use strict'
|
71 |
|
72 | const findout = require('findout')
|
73 |
|
74 | // Resolve a module path.
|
75 | let pathOfFoo = findout.resolve('foo')
|
76 |
|
77 | // Find and require a module.
|
78 | let foo = findout('foo', {
|
79 | cwd: __dirname // Lookup from current directory.
|
80 | })
|
81 |
|
82 |
|
83 | ```
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | <a name="section-doc-readme-03-how-md"></a>
|
91 | How It Works
|
92 | ------------
|
93 |
|
94 | When you call `findout` for "foo" with '/bar/baz' as current working directory:
|
95 |
|
96 | ```javascript
|
97 | findout('foo', {
|
98 | cwd: '/bar/baz';
|
99 | });
|
100 | ```
|
101 |
|
102 | and it will try the following ways,
|
103 |
|
104 | 1. `require('foo')`
|
105 | 2. `require('/bar/baz/foo')`
|
106 | 3. `require('/bar/baz/node_modules/foo')`
|
107 | 4. `require('/bar/foo')`
|
108 | 5. `require('/bar/node_modules/foo')`
|
109 | 6. `require('/foo')`
|
110 | 7. `require('/node_modules/foo')`
|
111 |
|
112 | If it still can't find any, throws an error.
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 | <a name="section-doc-readme-04-options-md"></a>
|
120 | Options
|
121 | -------
|
122 |
|
123 | | Key | Type | Default | Description |
|
124 | | --- | --- | --- | --- |
|
125 | | cwd | string | process.cwd() | Working directory path. |
|
126 | | safe | boolean | false | No throw when not found. |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | <a name="license"></a>
|
136 |
|
137 | License
|
138 | -------
|
139 | This software is released under the [MIT License](https://github.com/okunishinishi/node-findout/blob/master/LICENSE).
|
140 |
|
141 |
|
142 |
|
143 |
|