index.js 547 B

123456789101112131415
  1. 'use strict';
  2. var env = process.env;
  3. var home = env.HOME;
  4. var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME;
  5. if (process.platform === 'win32') {
  6. module.exports = env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null;
  7. } else if (process.platform === 'darwin') {
  8. module.exports = home || (user ? '/Users/' + user : null) || null;
  9. } else if (process.platform === 'linux') {
  10. module.exports = home ||
  11. (user ? (process.getuid() === 0 ? '/root' : '/home/' + user) : null) || null;
  12. } else {
  13. module.exports = home || null;
  14. }