# load-pkg [![NPM version](https://img.shields.io/npm/v/load-pkg.svg)](https://www.npmjs.com/package/load-pkg) [![Build Status](https://img.shields.io/travis/jonschlinkert/load-pkg.svg)](https://travis-ci.org/jonschlinkert/load-pkg) [![Build Status](https://img.shields.io/travis/jonschlinkert/load-pkg.svg)](https://travis-ci.org/jonschlinkert/load-pkg)

> Loads the package.json from the root of the user's current project.

**HEADS UP!**

Breaking changes in v2.0. The main export is now a function that must be called. This is so that the package.json is lazily loaded when the function is called.

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i load-pkg --save
```

## async usage

```js
var loadPkg = require('load-pkg');

// get the package.json from the cwd
loadPkg(function(err, pkg) {
  console.log(pkg.name);
  //=> 'load-pkg'
});

// get the package.json from the specified directory
loadPkg('~/foo/bar', function(err, pkg) {
  console.log(pkg.name);
  //=> 'load-pkg'
});
```

## sync usage

```js
var pkg = require('load-pkg').sync(process.cwd());
console.log(pkg.name);
//=> 'load-pkg'
```

Specify the cwd or filepath to start from:

```js
var pkg = require('load-pkg').sync('a/b/c');
console.log(pkg.name);
//=> 'foo'
```

## Related projects

* [cwd](https://www.npmjs.com/package/cwd): Easily get the CWD (current working directory) of a project based on package.json, optionally starting… [more](https://www.npmjs.com/package/cwd) | [homepage](https://github.com/jonschlinkert/cwd)
* [find-pkg](https://www.npmjs.com/package/find-pkg): Find the first directory with a package.json, recursing up, starting with the given directory. | [homepage](https://github.com/jonschlinkert/find-pkg)
* [look-up](https://www.npmjs.com/package/look-up): Faster drop-in replacement for find-up and findup-sync. | [homepage](https://github.com/jonschlinkert/look-up)

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/load-pkg/issues/new).

## Author

**Brian Woodward**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2015 [Brian Woodward](https://github.com/doowb)
Released under the MIT license.

***

_This file was generated by [verb](https://github.com/verbose/verb) on December 13, 2015._