aboutsummaryrefslogtreecommitdiff
path: root/node_modules/fined/README.md
blob: 8788de09fe275c0c531bd2565ff2f99190af0a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Fined [![Build Status][travis-image]][travis-url] [![Build Status][appveyor-image]][appveyor-url]

> Find a file given a declaration of locations

[![NPM](https://nodei.co/npm/fined.png)](https://nodei.co/npm/fined/)

## Usage

```js
var fined = require('fined');

fined({ path: 'path/to/file', extensions: ['.js', '.json'] });
// => { path: '/absolute/path/to/file.js', extension: '.js' }  (if file exists)
// => null  (if file does not exist)

var opts = {
  name: '.app',
  cwd: '.',
  extensions: {
    'rc': 'default-rc-loader', 
    '.yml': 'default-yml-loader',
  },
};

fined({ path: '.' }, opts);
// => { path: '/absolute/of/cwd/.app.yml', extension: { '.yml': 'default-yml-loader' } }

fined({ path: '~', extensions: { 'rc': 'some-special-rc-loader' } }, opts);
// => { path: '/User/home/.apprc', extension: { 'rc': 'some-special-rc-loader' } }
```

## API

### fined(pathObj, opts) => object | null

#### Arguments:

* **pathObj** [string | object] : a path setting for finding a file.
* **opts** [object] : a plain object supplements `pathObj`.

   `pathObj` and `opts` can have same properties:

   * **path** [string] : a path string.
   * **name** [string] : a basename.
   * **extensions**: [string | array | object] : extensions.
   * **cwd**: a base directory of `path` and for finding up.
   * **findUp**: [boolean] : a flag to find up.

#### Return:

This function returns a plain object which consists of following properties if a file exists otherwise null.

   * **path** : an absolute path
   * **extension** : a string or a plain object of extension.


## License

MIT


[npm-image]: http://img.shields.io/badge/npm-v0.0.0-blue.svg
[npm-url]: https://www.npmjs.org/package/fined
[travis-image]: https://travis-ci.org/js-cli/fined.svg?branch=master
[travis-url]: https://travis-ci.org/js-cli/fined
[appveyor-image]: https://ci.appveyor.com/api/projects/status/github/js-cli/fined?branch=master&svg=true
[appveyor-url]: https://ci.appveyor.com/project/js-cli/fined