Initial commit
[yaffs-website] / node_modules / fined / README.md
1 # Fined [![Build Status][travis-image]][travis-url] [![Build Status][appveyor-image]][appveyor-url]
2
3 > Find a file given a declaration of locations
4
5 [![NPM](https://nodei.co/npm/fined.png)](https://nodei.co/npm/fined/)
6
7 ## Usage
8
9 ```js
10 var fined = require('fined');
11
12 fined({ path: 'path/to/file', extensions: ['.js', '.json'] });
13 // => { path: '/absolute/path/to/file.js', extension: '.js' }  (if file exists)
14 // => null  (if file does not exist)
15
16 var opts = {
17   name: '.app',
18   cwd: '.',
19   extensions: {
20     'rc': 'default-rc-loader', 
21     '.yml': 'default-yml-loader',
22   },
23 };
24
25 fined({ path: '.' }, opts);
26 // => { path: '/absolute/of/cwd/.app.yml', extension: { '.yml': 'default-yml-loader' } }
27
28 fined({ path: '~', extensions: { 'rc': 'some-special-rc-loader' } }, opts);
29 // => { path: '/User/home/.apprc', extension: { 'rc': 'some-special-rc-loader' } }
30 ```
31
32 ## API
33
34 ### fined(pathObj, opts) => object | null
35
36 #### Arguments:
37
38 * **pathObj** [string | object] : a path setting for finding a file.
39 * **opts** [object] : a plain object supplements `pathObj`.
40
41    `pathObj` and `opts` can have same properties:
42
43    * **path** [string] : a path string.
44    * **name** [string] : a basename.
45    * **extensions**: [string | array | object] : extensions.
46    * **cwd**: a base directory of `path` and for finding up.
47    * **findUp**: [boolean] : a flag to find up.
48
49 #### Return:
50
51 This function returns a plain object which consists of following properties if a file exists otherwise null.
52
53    * **path** : an absolute path
54    * **extension** : a string or a plain object of extension.
55
56
57 ## License
58
59 MIT
60
61
62 [npm-image]: http://img.shields.io/badge/npm-v0.0.0-blue.svg
63 [npm-url]: https://www.npmjs.org/package/fined
64 [travis-image]: https://travis-ci.org/js-cli/fined.svg?branch=master
65 [travis-url]: https://travis-ci.org/js-cli/fined
66 [appveyor-image]: https://ci.appveyor.com/api/projects/status/github/js-cli/fined?branch=master&svg=true
67 [appveyor-url]: https://ci.appveyor.com/project/js-cli/fined