web 3d图形渲染器
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.

68 lines
1.2 KiB

  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 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. (async () => {
  22. console.log(await pkgUp());
  23. //=> '/Users/sindresorhus/foo/package.json'
  24. })();
  25. ```
  26. ## API
  27. ### pkgUp([options])
  28. Returns a `Promise<string>` for the filepath, or `Promise<null>` if it couldn't be found.
  29. ### pkgUp.sync([options])
  30. Returns the filepath, or `null` if it couldn't be found.
  31. #### options
  32. Type: `Object`
  33. #### cwd
  34. Type: `string`<br>
  35. Default: `process.cwd()`
  36. Directory to start from.
  37. ## Related
  38. - [read-pkg-up](https://github.com/sindresorhus/read-pkg-up) - Read the closest package.json file
  39. - [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
  40. - [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
  41. ## License
  42. MIT © [Sindre Sorhus](https://sindresorhus.com)