Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 46 lines (34 sloc) 1.143 kB
7885443 @substack readme before any code
authored
1 resolve
2 =======
3
4 Implements the [node `require.resolve()`
5 algorithm](http://nodejs.org/docs/v0.4.8/api/all.html#all_Together...)
6 except you can pass in the file to compute paths relatively to along with your
7 own `require.paths` without updating the global copy (which doesn't even work in
8 node `>=0.5`).
9
10 methods
11 =======
12
5218f01 @substack implementation seems to work but no tests yet
authored
13 var resolve = require('resolve');
14
2ad8287 @substack bump and a note in the docs for extensions
authored
15 resolve.sync(pkg, opts)
16 -----------------------
7885443 @substack readme before any code
authored
17
5218f01 @substack implementation seems to work but no tests yet
authored
18 Synchronously search for the package/filename string `pkg`
7885443 @substack readme before any code
authored
19 according to the [`require.resolve()`
20 algorithm](http://nodejs.org/docs/v0.4.8/api/all.html#all_Together...)
78010b1 @substack opts.path => opts.basedir, more descriptive I think
authored
21 for `X=pkg` and `Y=opts.basedir`.
7885443 @substack readme before any code
authored
22
2ad8287 @substack bump and a note in the docs for extensions
authored
23 Default values for `opts`:
24
25 ````javascript
9fbb632 @substack bump for packageFilter and a note in the docs
authored
26 {
27 paths : [],
28 basedir : __dirname,
29 extensions : [ '.js' ],
b0af4c3 @substack doc updates and a minor bump for custom isFile and readFileSync params
authored
30 readFileSync : fs.readFileSync,
31 isFile : function (file) {
32 return path.existSync(file) && fs.statSync(file).isFile()
33 }
9fbb632 @substack bump for packageFilter and a note in the docs
authored
34 }
2ad8287 @substack bump and a note in the docs for extensions
authored
35 ````
36
9fbb632 @substack bump for packageFilter and a note in the docs
authored
37 Optionally you can specify a `opts.packageFilter` function to map the contents
38 of `JSON.parse()`'d package.json files.
39
78010b1 @substack opts.path => opts.basedir, more descriptive I think
authored
40 If nothing is found, all of the directories in `opts.paths` are searched.
a9ef081 @substack new resolve.{core,isCore} with tests and documentation, bump to 0.0.1
authored
41
42 resolve.isCore(pkg)
43 -------------------
44
45 Return whether a package is in core.
Something went wrong with that request. Please try again.