homedir-current
This is a wrapper analagous to the module homedir
Uses passwd-darwin
for more support on unix-based platforms.
Install using
npm install --save homedir-current
Usage
The module exports a single function, similar to homedir
, but the function
takes options and a callback in the form homedir([options,] callback)
.
Get the current running user's homedir
var homedir = require('homedir-current');
homedir(console.log); // => As root this prints `/var/root`
Sometimes you want to run a process as root for some reason, but put files into the home directory of the running user, to make this simple there is an option for checking for sudo'd commands.
var homedir = require('homedir-current');
homedir({sudo: true}, console.log); // => Prints the directory of the user who ran the command as sudo
License
ISC