"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/os-homedir/index.js" (8 Mar 2017, 608 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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