Sha256: d9166450c8884ac225ab191965f527d74f8c1803036ec812cffb054ecba75ad1

Contents?: true

Size: 1.67 KB

Versions: 35

Compression:

Stored size: 1.67 KB

Contents

# read-pkg-up [![Build Status](https://travis-ci.org/sindresorhus/read-pkg-up.svg?branch=master)](https://travis-ci.org/sindresorhus/read-pkg-up)

> Read the closest package.json file


## Why

- [Finds the closest package.json](https://github.com/sindresorhus/find-up)
- [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
- [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
- [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
- [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)


## Install

```
$ npm install --save read-pkg-up
```


## Usage

```js
var readPkgUp = require('read-pkg-up');

readPkgUp().then(function (result) {
	console.log(result);
	/*
	{
		pkg: {
			name: 'awesome-package',
			version: '1.0.0',
			...
		},
		path: '/Users/sindresorhus/dev/awesome-package'
	}
	*/
});
```


## API

### readPkgUp([options])

Returns a promise that resolves to a result object.

### readPkgUp.sync([options])

Returns a result object.

#### options

##### cwd

Type: `string`  
Default: `.`

Directory to start looking for a package.json file.

##### normalize

Type: `boolean`  
Default: `true`

[Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.


## Related

- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
- [pkg-conf](https://github.com/sindresorhus/pkg-conf) - Get namespaced config from the closest package.json


## License

MIT © [Sindre Sorhus](http://sindresorhus.com)

Version data entries

35 entries across 34 versions & 15 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/read-pkg-up/readme.md
disco_app-0.18.0 test/dummy/node_modules/read-pkg-up/readme.md
disco_app-0.18.2 test/dummy/node_modules/read-pkg-up/readme.md
tang-0.2.1 spec/tang_app/node_modules/read-pkg-up/readme.md
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/read-pkg-up/readme.md
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/read-pkg-up/readme.md
ruby2js-4.0.4 lib/tasks/testrails/node_modules/read-pkg-up/readme.md
ruby2js-4.0.3 lib/tasks/testrails/node_modules/read-pkg-up/readme.md
tang-0.2.0 spec/tang_app/node_modules/read-pkg-up/readme.md
tang-0.1.0 spec/tang_app/node_modules/read-pkg-up/readme.md
tang-0.0.9 spec/tang_app/node_modules/read-pkg-up/readme.md
enju_library-0.3.8 spec/dummy/node_modules/read-pkg-up/readme.md
ilog-0.4.1 node_modules/read-pkg-up/readme.md
ilog-0.4.0 node_modules/read-pkg-up/readme.md
ilog-0.3.3 node_modules/read-pkg-up/readme.md
jester-data-8.0.0 node_modules/read-pkg-up/readme.md
ezii-os-5.2.1 node_modules/read-pkg-up/readme.md
ezii-os-2.0.1 node_modules/read-pkg-up/readme.md
ezii-os-1.1.0 node_modules/read-pkg-up/readme.md
ezii-os-1.0.0 node_modules/read-pkg-up/readme.md