paths.js 732 B

12345678910111213141516171819202122232425
  1. /**
  2. * @author oldj
  3. * @blog http://oldj.net
  4. */
  5. 'use strict';
  6. const path = require('path');
  7. const util = require('./util');
  8. const platform = process.platform;
  9. const sys_host_path = platform == 'win32' ?
  10. `${process.env.windir || 'C:\\WINDOWS'}\\system32\\drivers\\etc\\hosts` : // Windows 系统有可能不安装在 C 盘
  11. '/etc/hosts';
  12. const home_path = util.getUserHome();
  13. const work_path = path.join(home_path, '.SwitchHosts');
  14. const data_path = path.join(work_path, 'data.json');
  15. const preference_path = path.join(work_path, 'preferences.json');
  16. module.exports = {
  17. home_path: home_path,
  18. work_path: work_path,
  19. data_path: data_path,
  20. preference_path: preference_path,
  21. sys_host_path: sys_host_path
  22. };