Projekt

Obecné

Profil

Stáhnout (3.75 KB) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
# homedir-polyfill [![NPM version](https://img.shields.io/npm/v/homedir-polyfill.svg?style=flat)](https://www.npmjs.com/package/homedir-polyfill) [![NPM monthly downloads](https://img.shields.io/npm/dm/homedir-polyfill.svg?style=flat)](https://npmjs.org/package/homedir-polyfill) [![NPM total downloads](https://img.shields.io/npm/dt/homedir-polyfill.svg?style=flat)](https://npmjs.org/package/homedir-polyfill) [![Linux Build Status](https://img.shields.io/travis/doowb/homedir-polyfill.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/homedir-polyfill) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/homedir-polyfill.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/doowb/homedir-polyfill)
2
3
> Node.js os.homedir polyfill for older versions of node.js.
4
5
Please consider following this project's author, [Brian Woodward](https://github.com/doowb), and consider starring the project to show your :heart: and support.
6
7
## Install
8
9
Install with [npm](https://www.npmjs.com/):
10
11
```sh
12
$ npm install --save homedir-polyfill
13
```
14
15
## Usage
16
17
```js
18
var homedir = require('homedir-polyfill');
19
console.log(homedir());
20
//=> /Users/doowb
21
```
22
23
## Reasoning
24
25
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.
26
27
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.
28
29
Since `/etc/passwd` is not available on windows platforms, this implementation will use environment variables to find the home directory.
30
31
In modern versions of node.js, [os.homedir](https://nodejs.org/api/os.html#os_os_homedir) is used.
32
33
## About
34
35
<details>
36
<summary><strong>Contributing</strong></summary>
37
38
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
39
40
Please read the [contributing guide](contributing.md) for advice on opening issues, pull requests, and coding standards.
41
42
</details>
43
44
<details>
45
<summary><strong>Running Tests</strong></summary>
46
47
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
48
49
```sh
50
$ npm install && npm test
51
```
52
53
</details>
54
55
<details>
56
<summary><strong>Building docs</strong></summary>
57
58
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
59
60
To generate the readme, run the following command:
61
62
```sh
63
$ npm install -g verbose/verb#dev verb-generate-readme && verb
64
```
65
66
</details>
67
68
### Related projects
69
70
You might also be interested in these projects:
71
72
[parse-passwd](https://www.npmjs.com/package/parse-passwd): Parse a passwd file into a list of users. | [homepage](https://github.com/doowb/parse-passwd "Parse a passwd file into a list of users.")
73
74
### Contributors
75
76
| **Commits** | **Contributor** |  
77
| --- | --- |  
78
| 19 | [doowb](https://github.com/doowb) |  
79
| 2  | [martinheidegger](https://github.com/martinheidegger) |  
80
81
### Author
82
83
**Brian Woodward**
84
85
* [GitHub Profile](https://github.com/doowb)
86
* [Twitter Profile](https://twitter.com/doowb)
87
* [LinkedIn Profile](https://linkedin.com/in/woodwardbrian)
88
89
### License
90
91
Copyright © 2016 - 2019, [Brian Woodward](https://github.com/doowb).
92
Released under the [MIT License](LICENSE).
93
94
***
95
96
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on February 21, 2019._