1.0.0 • Published 10 years ago
real-homedir v1.0.0
Real Homedir
Get real home directory in node.js.
Why This Package?
Consider this situation:
You're user blah. You run command $ sudo -u foo node bar.js and bar.js will write some file in executor's (foo) home directory.
$HOME
When you use process.env.HOME in bar.js with above command, you may won't get /home/foo but get /home/blah.
os.homedir()
When you use os module shown below:
const os = require("os");
console.log(os.homedir());You may won't get /home/foo but get /home/blah too due to code of node.js and libuv.
So
You need this package to get the real home directory of current executor due to the situation above, and not only the situation above!
Installation
$ npm install -d --save real-homedirUsage
Require this package first:
const homedir = require("real-homedir");And just call it.
const hd = homedir();Then you will get the real home directory!
Contribution
You're welcome to make pull requests!
「雖然我覺得不怎麼可能有人會關注我」
1.0.0
10 years ago