You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

readme.md 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. > Read the closest package.json file
  3. ## Why
  4. - [Finds the closest package.json](https://github.com/sindresorhus/find-up)
  5. - [Gracefully handles filesystem issues](https://github.com/isaacs/node-graceful-fs)
  6. - [Strips UTF-8 BOM](https://github.com/sindresorhus/strip-bom)
  7. - [Throws more helpful JSON errors](https://github.com/sindresorhus/parse-json)
  8. - [Normalizes the data](https://github.com/npm/normalize-package-data#what-normalization-currently-entails)
  9. ## Install
  10. ```
  11. $ npm install --save read-pkg-up
  12. ```
  13. ## Usage
  14. ```js
  15. var readPkgUp = require('read-pkg-up');
  16. readPkgUp().then(function (result) {
  17. console.log(result);
  18. /*
  19. {
  20. pkg: {
  21. name: 'awesome-package',
  22. version: '1.0.0',
  23. ...
  24. },
  25. path: '/Users/sindresorhus/dev/awesome-package'
  26. }
  27. */
  28. });
  29. ```
  30. ## API
  31. ### readPkgUp([options])
  32. Returns a promise that resolves to a result object.
  33. ### readPkgUp.sync([options])
  34. Returns a result object.
  35. #### options
  36. ##### cwd
  37. Type: `string`
  38. Default: `.`
  39. Directory to start looking for a package.json file.
  40. ##### normalize
  41. Type: `boolean`
  42. Default: `true`
  43. [Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data.
  44. ## Related
  45. - [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a package.json file
  46. - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
  47. - [pkg-conf](https://github.com/sindresorhus/pkg-conf) - Get namespaced config from the closest package.json
  48. ## License
  49. MIT © [Sindre Sorhus](http://sindresorhus.com)