index.js 720 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const os = require('os');
  3. const path = require('path');
  4. const home = os.homedir();
  5. const env = process.env;
  6. exports.data = env.XDG_DATA_HOME ||
  7. (home ? path.join(home, '.local', 'share') : null);
  8. exports.config = env.XDG_CONFIG_HOME ||
  9. (home ? path.join(home, '.config') : null);
  10. exports.cache = env.XDG_CACHE_HOME || (home ? path.join(home, '.cache') : null);
  11. exports.runtime = env.XDG_RUNTIME_DIR || null;
  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. }