index.js 725 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. var path = require('path');
  3. var osHomedir = require('os-homedir');
  4. var home = osHomedir();
  5. var 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. }