Ingen beskrivning

index.js 608B

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