index.d.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. declare namespace globalDirectories {
  2. interface GlobalDirectories {
  3. /**
  4. Directory with globally installed packages.
  5. Equivalent to `npm root --global`.
  6. */
  7. readonly packages: string;
  8. /**
  9. Directory with globally installed binaries.
  10. Equivalent to `npm bin --global`.
  11. */
  12. readonly binaries: string;
  13. /**
  14. Directory with directories for packages and binaries. You probably want either of the above.
  15. Equivalent to `npm prefix --global`.
  16. */
  17. readonly prefix: string;
  18. }
  19. }
  20. declare const globalDirectories: {
  21. /**
  22. Get the directory of globally installed packages and binaries.
  23. @example
  24. ```
  25. import globalDirectories = require('global-dirs');
  26. console.log(globalDirectories.npm.prefix);
  27. //=> '/usr/local'
  28. console.log(globalDirectories.npm.packages);
  29. //=> '/usr/local/lib/node_modules'
  30. ```
  31. */
  32. readonly npm: globalDirectories.GlobalDirectories;
  33. /**
  34. Get the directory of globally installed packages and binaries.
  35. @example
  36. ```
  37. import globalDirectories = require('global-dirs');
  38. console.log(globalDirectories.npm.binaries);
  39. //=> '/usr/local/bin'
  40. console.log(globalDirectories.yarn.packages);
  41. //=> '/Users/sindresorhus/.config/yarn/global/node_modules'
  42. ```
  43. */
  44. readonly yarn: globalDirectories.GlobalDirectories;
  45. }
  46. export = globalDirectories;