|
|
||
|---|---|---|
| .. | ||
| bin | ||
| docs | ||
| etc | ||
| lib | ||
| package.json | ||
| README.md | ||
homedir
Return the current user's home directory.
Usage
var homedir = require( '@stdlib/os/homedir' );
homedir()
Returns the current user's home directory.
var home = homedir();
// e.g., returns '/Users/<username>'
If unable to locate a home directory, the function returns null.
Notes
- The implementation primarily checks various environment variables to locate a
homedirectory. Note that this approach has security vulnerabilities, as attackers can tamper with environment variables.
Examples
var homedir = require( '@stdlib/os/homedir' );
console.log( homedir() );
CLI
Usage
Usage: homedir [options]
Options:
-h, --help Print this message.
-V, --version Print the package version.
Examples
$ homedir
e.g., /Users/<username>