Initial commit
[yaffs-website] / node_modules / read-pkg-up / readme.md
1 # read-pkg-up [![Build Status](https://travis-ci.org/sindresorhus/read-pkg-up.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg-up)
2
3 > Read the closest package.json file
4
5
6 ## Why
7
8 - [Finds the closest package.json](https://github.com/sindresorhus/find-up)
9 - [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
10 - [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
11 - [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
12 - [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)
13
14
15 ## Install
16
17 ```
18 $ npm install --save read-pkg-up
19 ```
20
21
22 ## Usage
23
24 ```js
25 var readPkgUp = require('read-pkg-up');
26
27 readPkgUp().then(function (result) {
28         console.log(result);
29         /*
30         {
31                 pkg: {
32                         name: 'awesome-package',
33                         version: '1.0.0',
34                         ...
35                 },
36                 path: '/Users/sindresorhus/dev/awesome-package'
37         }
38         */
39 });
40 ```
41
42
43 ## API
44
45 ### readPkgUp([options])
46
47 Returns a promise that resolves to a result object.
48
49 ### readPkgUp.sync([options])
50
51 Returns a result object.
52
53 #### options
54
55 ##### cwd
56
57 Type: `string`  
58 Default: `.`
59
60 Directory to start looking for a package.json file.
61
62 ##### normalize
63
64 Type: `boolean`  
65 Default: `true`
66
67 [Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
68
69
70 ## Related
71
72 - [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
73 - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
74 - [pkg-conf](https://github.com/sindresorhus/pkg-conf) - Get namespaced config from the closest package.json
75
76
77 ## License
78
79 MIT © [Sindre Sorhus](http://sindresorhus.com)