├── .eslintrc ├── .gitignore ├── .editorconfig ├── index.js ├── package.json ├── License.md ├── Readme.md └── Contributing.md /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tamia" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | Thumbs.db 4 | .idea/ 5 | .vscode/ 6 | *.sublime-project 7 | *.sublime-workspace 8 | *.log 9 | .eslintcache -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.{json,yml,md,babelrc,eslintrc,remarkrc}] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const rc = require('rc'); 2 | const execSync = require('child_process').execSync; 3 | 4 | const npm = rc('npm', null, []); 5 | 6 | module.exports = { 7 | name: npm['init-author-name'] || execSync('git config user.name').toString().trim(), 8 | email: npm['init-author-email'] || execSync('git config user.email').toString().trim(), 9 | url: npm['init-author-url'], 10 | }; 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "user-meta", 3 | "version": "1.0.0", 4 | "description": "Read user name, email and URL from .npmrc or .gitconfig", 5 | "author": { 6 | "name": "Artem Sapegin", 7 | "url": "http://sapegin.me" 8 | }, 9 | "homepage": "https://github.com/sapegin/user-meta", 10 | "repository": "sapegin/user-meta", 11 | "license": "MIT", 12 | "engines": { 13 | "node": ">=4" 14 | }, 15 | "main": "index.js", 16 | "files": [ 17 | "index.js" 18 | ], 19 | "scripts": { 20 | "lint": "eslint . --cache --fix", 21 | "test": "npm run lint" 22 | }, 23 | "keywords": [ 24 | "npm", 25 | "npmrc", 26 | "git", 27 | "gitconfig", 28 | "name", 29 | "username", 30 | "user", 31 | "url", 32 | "config", 33 | "configuration" 34 | ], 35 | "devDependencies": { 36 | "eslint": "^4.5.0", 37 | "eslint-config-tamia": "^4.1.2", 38 | "eslint-plugin-prettier": "^2.2.0", 39 | "prettier": "^1.5.3" 40 | }, 41 | "dependencies": { 42 | "rc": "^1.2.1" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | The MIT License 2 | =============== 3 | 4 | Copyright 2017 Artem Sapegin (http://sapegin.me), contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | 'Software'), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # user-meta 2 | 3 | Read user name, email and URL from `.npmrc` or `.gitconfig`. 4 | 5 | ## Installation 6 | 7 | ```shell 8 | npm install user-meta 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | const { name, email, url } = require('user-meta'); 15 | ``` 16 | 17 | ## How it works 18 | 19 | It tries to read data from your npm and Git configs: 20 | 21 | | Property | npm | Git | 22 | | -------- | --- | --- | 23 | | `name` | `npm get init-author-name` | `git config user.name` | 24 | | `email` | `npm get init-author-email` | `git config user.email` | 25 | | `url` | `npm get init-author-url` | — | 26 | 27 | Npm has priority over Git. `git` binary is required and used to read Git configuration. Don’t use this module if performance is important. 28 | 29 | ## Changelog 30 | 31 | The changelog can be found on the [Releases page](https://github.com/sapegin/user-meta/releases). 32 | 33 | ## Contributing 34 | 35 | Everyone is welcome to contribute. Please take a moment to review the [contributing guidelines](Contributing.md). 36 | 37 | ## Authors and license 38 | 39 | [Artem Sapegin](http://sapegin.me) and [contributors](https://github.com/sapegin/user-meta/graphs/contributors). 40 | 41 | MIT License, see the included [License.md](License.md) file. 42 | -------------------------------------------------------------------------------- /Contributing.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | I love pull requests. And following this simple guidelines will make your pull request easier to merge. 4 | 5 | ## Submitting pull requests 6 | 7 | 1. Create a new branch, please don’t work in master directly. 8 | 2. Add failing tests (if there’re any tests in project) for the change you want to make. Run tests (see below) to see the tests fail. 9 | 3. Hack on. 10 | 4. Run tests to see if the tests pass. Repeat steps 2–4 until done. 11 | 5. Update the documentation to reflect any changes. 12 | 6. Push to your fork and submit a pull request. 13 | 14 | ## JavaScript code style 15 | 16 | [See here](https://github.com/tamiadev/eslint-config-tamia#code-style-at-a-glance). 17 | 18 | ## Other notes 19 | 20 | - If you have commit access to repository and want to make big change or not sure about something, make a new branch and open pull request. 21 | - Don’t commit generated files: compiled from Stylus CSS, minified JavaScript, etc. 22 | - Don’t change version number and change log. 23 | - Install [EditorConfig](http://editorconfig.org/) plugin for your code editor. 24 | - Feel free to [ask me](http://sapegin.me) anything you need. 25 | 26 | ## Building and running tests 27 | 28 | Install dependencies: 29 | 30 | ```bash 31 | npm install 32 | ``` 33 | 34 | Run tests: 35 | 36 | ```bash 37 | npm test 38 | ``` 39 | --------------------------------------------------------------------------------