Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BoogeeDoo/real-homedir
Get real home directory in node.js.
https://github.com/BoogeeDoo/real-homedir
Last synced: 2 months ago
JSON representation
Get real home directory in node.js.
- Host: GitHub
- URL: https://github.com/BoogeeDoo/real-homedir
- Owner: BoogeeDoo
- License: mit
- Created: 2016-03-03T08:57:14.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-03-12T14:21:57.000Z (almost 9 years ago)
- Last Synced: 2024-10-04T12:07:04.441Z (4 months ago)
- Language: C++
- Size: 14.6 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-github-star - real-homedir
README
# Real Homedir
[![Real Homedir](http://img.shields.io/npm/v/real-homedir.svg)](https://www.npmjs.org/package/real-homedir)
[![Real Homedir](http://img.shields.io/npm/dm/real-homedir.svg)](https://www.npmjs.org/package/real-homedir)
[![Build Status](https://travis-ci.org/BoogeeDoo/real-homedir.svg?branch=master)](https://travis-ci.org/BoogeeDoo/real-homedir)
[![Coverage Status](https://img.shields.io/coveralls/BoogeeDoo/real-homedir/master.svg)](https://coveralls.io/r/BoogeeDoo/real-homedir?branch=master)
[![License](https://img.shields.io/npm/l/real-homedir.svg?style=flat)](https://www.npmjs.org/package/real-homedir)
[![Dependency Status](https://david-dm.org/BoogeeDoo/real-homedir.svg)](https://david-dm.org/BoogeeDoo/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:
```javascript
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](https://github.com/nodejs/node/blob/v4.3.2/src/node_os.cc#L274-L290) and [libuv](https://github.com/libuv/libuv/blob/v1.8.0/src/unix/core.c#L1032).
### 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
```sh
$ npm install -d --save real-homedir
```## Usage
Require this package first:
```javascript
const homedir = require("real-homedir");
```And just call it.
```javascript
const hd = homedir();
```Then you will get the real home directory!
## Contribution
You're welcome to make pull requests!
「雖然我覺得不怎麼可能有人會關注我」