index.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. declare const resolveCwd: {
  2. /**
  3. Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from the current working directory.
  4. @param moduleId - What you would use in `require()`.
  5. @returns The resolved module path.
  6. @throws When the module can't be found.
  7. @example
  8. ```
  9. import resolveCwd = require('resolve-cwd');
  10. console.log(__dirname);
  11. //=> '/Users/sindresorhus/rainbow'
  12. console.log(process.cwd());
  13. //=> '/Users/sindresorhus/unicorn'
  14. console.log(resolveCwd('./foo'));
  15. //=> '/Users/sindresorhus/unicorn/foo.js'
  16. ```
  17. */
  18. (moduleId: string): string;
  19. /**
  20. Resolve the path of a module like [`require.resolve()`](https://nodejs.org/api/globals.html#globals_require_resolve) but from the current working directory.
  21. @param moduleId - What you would use in `require()`.
  22. @returns The resolved module path. Returns `undefined` instead of throwing when the module can't be found.
  23. @example
  24. ```
  25. import resolveCwd = require('resolve-cwd');
  26. console.log(__dirname);
  27. //=> '/Users/sindresorhus/rainbow'
  28. console.log(process.cwd());
  29. //=> '/Users/sindresorhus/unicorn'
  30. console.log(resolveCwd.silent('./foo'));
  31. //=> '/Users/sindresorhus/unicorn/foo.js'
  32. ```
  33. */
  34. silent(moduleId: string): string | undefined;
  35. };
  36. export = resolveCwd;