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.

index.d.ts 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. declare const pkgDir: {
  2. /**
  3. Find the root directory of a Node.js project or npm package.
  4. @param cwd - Directory to start from. Default: `process.cwd()`.
  5. @returns The project root path or `undefined` if it couldn't be found.
  6. @example
  7. ```
  8. // /
  9. // └── Users
  10. // └── sindresorhus
  11. // └── foo
  12. // ├── package.json
  13. // └── bar
  14. // ├── baz
  15. // └── example.js
  16. // example.js
  17. import pkgDir = require('pkg-dir');
  18. (async () => {
  19. const rootDir = await pkgDir(__dirname);
  20. console.log(rootDir);
  21. //=> '/Users/sindresorhus/foo'
  22. })();
  23. ```
  24. */
  25. (cwd?: string): Promise<string | undefined>;
  26. /**
  27. Synchronously find the root directory of a Node.js project or npm package.
  28. @param cwd - Directory to start from. Default: `process.cwd()`.
  29. @returns The project root path or `undefined` if it couldn't be found.
  30. */
  31. sync(cwd?: string): string | undefined;
  32. // TODO: Remove this for the next major release
  33. default: typeof pkgDir;
  34. };
  35. export = pkgDir;