Debian Codegraph @

homedir-polyfill/.verb.md

raw
1 ## Usage
2
3 ```js
4 var homedir = require('{%= name %}');
5 console.log(homedir());
6 //=> /Users/doowb
7 ```
8
9 ## Reasoning
10
11 This library is a polyfill for the [node.js os.homedir](https://nodejs.org/api/os.html#os_os_homedir) method found in modern versions of node.js.
12
13 This implementation tries to follow the implementation found in `libuv` by finding the current user using the `process.geteuid()` method and the `/etc/passwd` file. This should usually work in a linux environment, but will also fallback to looking at user specific environment variables to build the user's home directory if neccessary.
14
15 Since `/etc/passwd` is not available on windows platforms, this implementation will use environment variables to find the home directory.
16
17 In modern versions of node.js, [os.homedir](https://nodejs.org/api/os.html#os_os_homedir) is used.