You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # 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. > Node.js os.homedir polyfill for older versions of node.js.
  3. Please consider following this project's author, [Brian Woodward](https://github.com/doowb), and consider starring the project to show your :heart: and support.
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/):
  6. ```sh
  7. $ npm install --save homedir-polyfill
  8. ```
  9. ## Usage
  10. ```js
  11. var homedir = require('homedir-polyfill');
  12. console.log(homedir());
  13. //=> /Users/doowb
  14. ```
  15. ## Reasoning
  16. 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.
  17. 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.
  18. Since `/etc/passwd` is not available on windows platforms, this implementation will use environment variables to find the home directory.
  19. In modern versions of node.js, [os.homedir](https://nodejs.org/api/os.html#os_os_homedir) is used.
  20. ## About
  21. <details>
  22. <summary><strong>Contributing</strong></summary>
  23. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  24. Please read the [contributing guide](contributing.md) for advice on opening issues, pull requests, and coding standards.
  25. </details>
  26. <details>
  27. <summary><strong>Running Tests</strong></summary>
  28. 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:
  29. ```sh
  30. $ npm install && npm test
  31. ```
  32. </details>
  33. <details>
  34. <summary><strong>Building docs</strong></summary>
  35. _(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.)_
  36. To generate the readme, run the following command:
  37. ```sh
  38. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  39. ```
  40. </details>
  41. ### Related projects
  42. You might also be interested in these projects:
  43. [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.")
  44. ### Contributors
  45. | **Commits** | **Contributor** |
  46. | --- | --- |
  47. | 19 | [doowb](https://github.com/doowb) |
  48. | 2 | [martinheidegger](https://github.com/martinheidegger) |
  49. ### Author
  50. **Brian Woodward**
  51. * [GitHub Profile](https://github.com/doowb)
  52. * [Twitter Profile](https://twitter.com/doowb)
  53. * [LinkedIn Profile](https://linkedin.com/in/woodwardbrian)
  54. ### License
  55. Copyright © 2016 - 2019, [Brian Woodward](https://github.com/doowb).
  56. Released under the [MIT License](LICENSE).
  57. ***
  58. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on February 21, 2019._