index.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. declare namespace envPaths {
  2. export interface Options {
  3. /**
  4. __Don't use this option unless you really have to!__
  5. Suffix appended to the project name to avoid name conflicts with native apps. Pass an empty string to disable it.
  6. @default 'nodejs'
  7. */
  8. readonly suffix?: string;
  9. }
  10. export interface Paths {
  11. /**
  12. Directory for data files.
  13. Example locations (with the default `nodejs` suffix):
  14. - macOS: `~/Library/Application Support/MyApp-nodejs`
  15. - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Data` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Data`)
  16. - Linux: `~/.local/share/MyApp-nodejs` (or `$XDG_DATA_HOME/MyApp-nodejs`)
  17. */
  18. readonly data: string;
  19. /**
  20. Directory for data files.
  21. Example locations (with the default `nodejs` suffix):
  22. - macOS: `~/Library/Preferences/MyApp-nodejs`
  23. - Windows: `%APPDATA%\MyApp-nodejs\Config` (for example, `C:\Users\USERNAME\AppData\Roaming\MyApp-nodejs\Config`)
  24. - Linux: `~/.config/MyApp-nodejs` (or `$XDG_CONFIG_HOME/MyApp-nodejs`)
  25. */
  26. readonly config: string;
  27. /**
  28. Directory for non-essential data files.
  29. Example locations (with the default `nodejs` suffix):
  30. - macOS: `~/Library/Caches/MyApp-nodejs`
  31. - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Cache` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Cache`)
  32. - Linux: `~/.cache/MyApp-nodejs` (or `$XDG_CACHE_HOME/MyApp-nodejs`)
  33. */
  34. readonly cache: string;
  35. /**
  36. Directory for log files.
  37. Example locations (with the default `nodejs` suffix):
  38. - macOS: `~/Library/Logs/MyApp-nodejs`
  39. - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Log` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Log`)
  40. - Linux: `~/.local/state/MyApp-nodejs` (or `$XDG_STATE_HOME/MyApp-nodejs`)
  41. */
  42. readonly log: string;
  43. /**
  44. Directory for temporary files.
  45. Example locations (with the default `nodejs` suffix):
  46. - macOS: `/var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-nodejs`
  47. - Windows: `%LOCALAPPDATA%\Temp\MyApp-nodejs` (for example, `C:\Users\USERNAME\AppData\Local\Temp\MyApp-nodejs`)
  48. - Linux: `/tmp/USERNAME/MyApp-nodejs`
  49. */
  50. readonly temp: string;
  51. }
  52. }
  53. declare const envPaths: {
  54. /**
  55. Get paths for storing things like data, config, cache, etc.
  56. Note: It only generates the path strings. It doesn't create the directories for you. You could use [`make-dir`](https://github.com/sindresorhus/make-dir) to create the directories.
  57. @param name - Name of your project. Used to generate the paths.
  58. @returns The paths to use for your project on current OS.
  59. @example
  60. ```
  61. import envPaths = require('env-paths');
  62. const paths = envPaths('MyApp');
  63. paths.data;
  64. //=> '/home/sindresorhus/.local/share/MyApp-nodejs'
  65. paths.config
  66. //=> '/home/sindresorhus/.config/MyApp-nodejs'
  67. ```
  68. */
  69. (name: string, options?: envPaths.Options): envPaths.Paths;
  70. // TODO: Remove this for the next major release, refactor the whole definition to:
  71. // declare function envPaths(name: string, options?: envPaths.Options): envPaths.Paths;
  72. // export = envPaths;
  73. default: typeof envPaths;
  74. };
  75. export = envPaths;