diff options
author | 2020-11-16 00:10:28 +0100 | |
---|---|---|
committer | 2020-11-16 00:10:28 +0100 | |
commit | e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch) | |
tree | 55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/homedir-polyfill | |
download | website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2 website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip |
api, login, auth
Diffstat (limited to 'node_modules/homedir-polyfill')
-rw-r--r-- | node_modules/homedir-polyfill/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/homedir-polyfill/README.md | 96 | ||||
-rw-r--r-- | node_modules/homedir-polyfill/index.js | 9 | ||||
-rw-r--r-- | node_modules/homedir-polyfill/package.json | 94 | ||||
-rw-r--r-- | node_modules/homedir-polyfill/polyfill.js | 81 |
5 files changed, 301 insertions, 0 deletions
diff --git a/node_modules/homedir-polyfill/LICENSE b/node_modules/homedir-polyfill/LICENSE new file mode 100644 index 0000000..f92fdcf --- /dev/null +++ b/node_modules/homedir-polyfill/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Brian Woodward + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/homedir-polyfill/README.md b/node_modules/homedir-polyfill/README.md new file mode 100644 index 0000000..8770050 --- /dev/null +++ b/node_modules/homedir-polyfill/README.md @@ -0,0 +1,96 @@ +# homedir-polyfill [](https://www.npmjs.com/package/homedir-polyfill) [](https://npmjs.org/package/homedir-polyfill) [](https://npmjs.org/package/homedir-polyfill) [](https://travis-ci.org/doowb/homedir-polyfill) [](https://ci.appveyor.com/project/doowb/homedir-polyfill) + +> Node.js os.homedir polyfill for older versions of node.js. + +Please consider following this project's author, [Brian Woodward](https://github.com/doowb), and consider starring the project to show your :heart: and support. + +## Install + +Install with [npm](https://www.npmjs.com/): + +```sh +$ npm install --save homedir-polyfill +``` + +## Usage + +```js +var homedir = require('homedir-polyfill'); +console.log(homedir()); +//=> /Users/doowb +``` + +## Reasoning + +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. + +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. + +Since `/etc/passwd` is not available on windows platforms, this implementation will use environment variables to find the home directory. + +In modern versions of node.js, [os.homedir](https://nodejs.org/api/os.html#os_os_homedir) is used. + +## About + +<details> +<summary><strong>Contributing</strong></summary> + +Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). + +Please read the [contributing guide](contributing.md) for advice on opening issues, pull requests, and coding standards. + +</details> + +<details> +<summary><strong>Running Tests</strong></summary> + +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: + +```sh +$ npm install && npm test +``` + +</details> + +<details> +<summary><strong>Building docs</strong></summary> + +_(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.)_ + +To generate the readme, run the following command: + +```sh +$ npm install -g verbose/verb#dev verb-generate-readme && verb +``` + +</details> + +### Related projects + +You might also be interested in these projects: + +[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.") + +### Contributors + +| **Commits** | **Contributor** | +| --- | --- | +| 19 | [doowb](https://github.com/doowb) | +| 2 | [martinheidegger](https://github.com/martinheidegger) | + +### Author + +**Brian Woodward** + +* [GitHub Profile](https://github.com/doowb) +* [Twitter Profile](https://twitter.com/doowb) +* [LinkedIn Profile](https://linkedin.com/in/woodwardbrian) + +### License + +Copyright © 2016 - 2019, [Brian Woodward](https://github.com/doowb). +Released under the [MIT License](LICENSE). + +*** + +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on February 21, 2019._ diff --git a/node_modules/homedir-polyfill/index.js b/node_modules/homedir-polyfill/index.js new file mode 100644 index 0000000..298168e --- /dev/null +++ b/node_modules/homedir-polyfill/index.js @@ -0,0 +1,9 @@ +'use strict'; + +var os = require('os'); +if (typeof os.homedir !== 'undefined') { + module.exports = os.homedir; +} else { + module.exports = require('./polyfill.js'); +} + diff --git a/node_modules/homedir-polyfill/package.json b/node_modules/homedir-polyfill/package.json new file mode 100644 index 0000000..05aa3b1 --- /dev/null +++ b/node_modules/homedir-polyfill/package.json @@ -0,0 +1,94 @@ +{ + "_from": "homedir-polyfill@^1.0.1", + "_id": "homedir-polyfill@1.0.3", + "_inBundle": false, + "_integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "_location": "/homedir-polyfill", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "homedir-polyfill@^1.0.1", + "name": "homedir-polyfill", + "escapedName": "homedir-polyfill", + "rawSpec": "^1.0.1", + "saveSpec": null, + "fetchSpec": "^1.0.1" + }, + "_requiredBy": [ + "/expand-tilde", + "/global-prefix" + ], + "_resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "_shasum": "743298cef4e5af3e194161fbadcc2151d3a058e8", + "_spec": "homedir-polyfill@^1.0.1", + "_where": "/home/pruss/Dev/3-minute-website/node_modules/expand-tilde", + "author": { + "name": "Brian Woodward", + "url": "https://github.com/doowb" + }, + "bugs": { + "url": "https://github.com/doowb/homedir-polyfill/issues" + }, + "bundleDependencies": false, + "dependencies": { + "parse-passwd": "^1.0.0" + }, + "deprecated": false, + "description": "Node.js os.homedir polyfill for older versions of node.js.", + "devDependencies": { + "gulp-format-md": "^0.1.11", + "mocha": "^3.1.2" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js", + "polyfill.js", + "LICENSE" + ], + "homepage": "https://github.com/doowb/homedir-polyfill", + "keywords": [ + "home", + "homedir", + "homedirectory", + "os", + "os-homedir", + "polyfill", + "userhome" + ], + "license": "MIT", + "main": "index.js", + "name": "homedir-polyfill", + "repository": { + "type": "git", + "url": "git+https://github.com/doowb/homedir-polyfill.git" + }, + "scripts": { + "test": "mocha" + }, + "verb": { + "toc": false, + "layout": "default", + "tasks": [ + "readme" + ], + "plugins": [ + "gulp-format-md" + ], + "lint": { + "reflinks": true + }, + "related": { + "list": [ + "parse-passwd" + ] + }, + "reflinks": [ + "verb", + "verb-generate-readme" + ] + }, + "version": "1.0.3" +} diff --git a/node_modules/homedir-polyfill/polyfill.js b/node_modules/homedir-polyfill/polyfill.js new file mode 100644 index 0000000..83aee38 --- /dev/null +++ b/node_modules/homedir-polyfill/polyfill.js @@ -0,0 +1,81 @@ +'use strict'; + +var fs = require('fs'); +var parse = require('parse-passwd'); + +function homedir() { + // The following logic is from looking at logic used in the different platform + // versions of the uv_os_homedir function found in https://github.com/libuv/libuv + // This is the function used in modern versions of node.js + + if (process.platform === 'win32') { + // check the USERPROFILE first + if (process.env.USERPROFILE) { + return process.env.USERPROFILE; + } + + // check HOMEDRIVE and HOMEPATH + if (process.env.HOMEDRIVE && process.env.HOMEPATH) { + return process.env.HOMEDRIVE + process.env.HOMEPATH; + } + + // fallback to HOME + if (process.env.HOME) { + return process.env.HOME; + } + + return null; + } + + // check HOME environment variable first + if (process.env.HOME) { + return process.env.HOME; + } + + // on linux platforms (including OSX) find the current user and get their homedir from the /etc/passwd file + var passwd = tryReadFileSync('/etc/passwd'); + var home = find(parse(passwd), getuid()); + if (home) { + return home; + } + + // fallback to using user environment variables + var user = process.env.LOGNAME || process.env.USER || process.env.LNAME || process.env.USERNAME; + + if (!user) { + return null; + } + + if (process.platform === 'darwin') { + return '/Users/' + user; + } + + return '/home/' + user; +} + +function find(arr, uid) { + var len = arr.length; + for (var i = 0; i < len; i++) { + if (+arr[i].uid === uid) { + return arr[i].homedir; + } + } +} + +function getuid() { + if (typeof process.geteuid === 'function') { + return process.geteuid(); + } + return process.getuid(); +} + +function tryReadFileSync(fp) { + try { + return fs.readFileSync(fp, 'utf8'); + } catch (err) { + return ''; + } +} + +module.exports = homedir; + |