index.js 801 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const os = require('os');
  3. const path = require('path');
  4. const homeDirectory = os.homedir();
  5. const {env} = process;
  6. exports.data = env.XDG_DATA_HOME ||
  7. (homeDirectory ? path.join(homeDirectory, '.local', 'share') : undefined);
  8. exports.config = env.XDG_CONFIG_HOME ||
  9. (homeDirectory ? path.join(homeDirectory, '.config') : undefined);
  10. exports.cache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, '.cache') : undefined);
  11. exports.runtime = env.XDG_RUNTIME_DIR || undefined;
  12. exports.dataDirs = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':');
  13. if (exports.data) {
  14. exports.dataDirs.unshift(exports.data);
  15. }
  16. exports.configDirs = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':');
  17. if (exports.config) {
  18. exports.configDirs.unshift(exports.config);
  19. }