diff options
| author | Arman Shah <[email protected]> | 2018-02-19 23:50:04 -0800 |
|---|---|---|
| committer | Arman Shah <[email protected]> | 2018-02-19 23:50:04 -0800 |
| commit | ae34dcfd3823a609ba7182f2d6eda593be876f7d (patch) | |
| tree | b9d7f2884c4999349418cbdc4f9ab46d113e0afd /node_modules/home-path/lib | |
| parent | Initial commit (diff) | |
| download | launcher-ae34dcfd3823a609ba7182f2d6eda593be876f7d.tar.xz launcher-ae34dcfd3823a609ba7182f2d6eda593be876f7d.zip | |
add base files
Diffstat (limited to 'node_modules/home-path/lib')
| -rw-r--r-- | node_modules/home-path/lib/home-path.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/node_modules/home-path/lib/home-path.js b/node_modules/home-path/lib/home-path.js new file mode 100644 index 0000000..bff9e98 --- /dev/null +++ b/node_modules/home-path/lib/home-path.js @@ -0,0 +1,42 @@ +'use strict' +var os = require('os') + +/** +* Cross-platform home directory retriever, tested on Windows XP and above, Mac OSX and Linux. +* +* With node versions 2.3.0 (iojs) or higher, the built-in [`os.homedir`](https://nodejs.org/api/os.html#os_os_homedir) method is used. +* +* @module home-path +* @example +* var getHomePath = require('home-path') +*/ +module.exports = os.homedir ? os.homedir : getHomePath + +/** +* @alias module:home-path +* @example +* Mac OSX +* ```js +* > getHomePath() +* '/Users/Lloyd' +* ``` +* +* Ubuntu Linux +* ```js +* > getHomePath() +* '/home/lloyd' +* ``` +* +* Windows 8.1 +* ```js +* > getHomePath() +* 'C:\\Users\\Lloyd' +* ``` +*/ +function getHomePath () { + if (process.platform === 'win32') { + return process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || process.env.HOME + } else { + return process.env.HOME + } +} |