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.

readme.md 1.5KB

4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # xdg-basedir [![Build Status](https://travis-ci.org/sindresorhus/xdg-basedir.svg?branch=master)](https://travis-ci.org/sindresorhus/xdg-basedir)
  2. > Get [XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) paths
  3. ## Install
  4. ```
  5. $ npm install xdg-basedir
  6. ```
  7. ## Usage
  8. ```js
  9. const xdgBasedir = require('xdg-basedir');
  10. xdgBasedir.data;
  11. //=> '/home/sindresorhus/.local/share'
  12. xdgBasedir.config;
  13. //=> '/home/sindresorhus/.config'
  14. xdgBasedir.dataDirs
  15. //=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']
  16. ```
  17. ## API
  18. The properties `.data`, `.config`, `.cache`, `.runtime` will return `null` in the uncommon case that both the XDG environment variable is not set and the users home directory can't be found. You need to handle this case. A common solution is to [fall back to a temp directory](https://github.com/yeoman/configstore/blob/b82690fc401318ad18dcd7d151a0003a4898a314/index.js#L15).
  19. ### .data
  20. Directory for user-specific data files.
  21. ### .config
  22. Directory for user-specific configuration files.
  23. ### .cache
  24. Directory for user-specific non-essential data files.
  25. ### .runtime
  26. Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc).
  27. ### .dataDirs
  28. Preference-ordered array of base directories to search for data files in addition to `.data`.
  29. ### .configDirs
  30. Preference-ordered array of base directories to search for configuration files in addition to `.config`.
  31. ## License
  32. MIT © [Sindre Sorhus](https://sindresorhus.com)