web 3d图形渲染器

64 lines
1.2 KiB

  1. # pkg-dir [![Build Status](https://travis-ci.org/sindresorhus/pkg-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-dir)
  2. > Find the root directory of a Node.js project or npm package
  3. ## Install
  4. ```
  5. $ npm install --save pkg-dir
  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 pkgDir = require('pkg-dir');
  21. pkgDir(__dirname).then(rootDir => {
  22. console.log(rootDir);
  23. //=> '/Users/sindresorhus/foo'
  24. });
  25. ```
  26. ## API
  27. ### pkgDir([cwd])
  28. Returns a `Promise` for either the project root path or `null` if it couldn't be found.
  29. ### pkgDir.sync([cwd])
  30. Returns the project root path or `null`.
  31. #### cwd
  32. Type: `string`<br>
  33. Default: `process.cwd()`
  34. Directory to start from.
  35. ## Related
  36. - [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module
  37. - [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
  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)