No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

readme.md 1.2 KiB

hace 3 años
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # pkg-up [![Build Status](https://travis-ci.org/sindresorhus/pkg-up.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-up)
  2. > Find the closest package.json file
  3. ## Install
  4. ```
  5. $ npm install --save pkg-up
  6. ```
  7. ## Usage
  8. ```
  9. /
  10. └── Users
  11. └── sindresorhus
  12. └── foo
  13. ├── package.json
  14. └── bar
  15. ├── baz
  16. └── example.js
  17. ```
  18. ```js
  19. // example.js
  20. const pkgUp = require('pkg-up');
  21. pkgUp().then(filepath => {
  22. console.log(filepath);
  23. //=> '/Users/sindresorhus/foo/package.json'
  24. });
  25. ```
  26. ## API
  27. ### pkgUp([cwd])
  28. Returns a `Promise` for either the filepath or `null` if it could be found.
  29. ### pkgUp.sync([cwd])
  30. Returns the filepath or `null`.
  31. #### cwd
  32. Type: `string`
  33. Default: `process.cwd()`
  34. Directory to start from.
  35. ## Related
  36. - [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
  37. - [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
  38. - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
  39. ## License
  40. MIT © [Sindre Sorhus](https://sindresorhus.com)