├── .gitignore ├── LICENSE ├── README.md ├── cli.js ├── index.js ├── package.json └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2017 Eugene Sharygin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![npm](https://nodei.co/npm/npm-man.png)](https://nodei.co/npm/npm-man/) 2 | 3 | # npm-man 4 | 5 | [![Dependency Status][david-badge]][david] 6 | 7 | Fetches package's readme from the npm registry and renders it as a man page. 8 | 9 | [david]: https://david-dm.org/eush77/npm-man 10 | [david-badge]: https://david-dm.org/eush77/npm-man.png 11 | 12 | ![screenshot](screenshot.png) 13 | 14 | ## CLI 15 | 16 | ### `npm-man ` 17 | 18 | Opens readme for `` as a man page. 19 | 20 | ## API 21 | 22 | #### `npmMan(packageName, cb(err, man))` 23 | 24 | Fetches readme for `packageName` from the npm registry and returns it as a man page. 25 | 26 | ## Related 27 | 28 | - [github-man] — open README from GitHub repository as a man page. 29 | - [readman] - display local package readme as a man page. 30 | 31 | [github-man]: https://github.com/eush77/github-man 32 | [readman]: https://github.com/eush77/readman 33 | 34 | ## Install 35 | 36 | ``` 37 | npm install -g npm-man 38 | ``` 39 | 40 | ## License 41 | 42 | MIT 43 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | 4 | var npmMan = require('./'); 5 | 6 | var help = require('help-version')(usage()).help, 7 | manPager = require('man-pager'); 8 | 9 | 10 | function usage() { 11 | return [ 12 | 'Usage: npm-man ', 13 | '', 14 | 'Fetch from npm and open package readme as a man page.' 15 | ].join('\n'); 16 | } 17 | 18 | 19 | (function (argv) { 20 | if (argv.length != 1) { 21 | return help(argv.length); 22 | } 23 | 24 | npmMan(argv[0], function (err, man) { 25 | if (err) return console.error(err); 26 | manPager().end(man); 27 | }); 28 | }(process.argv.slice(2))); 29 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var registryUrl = require('registry-url')(), 4 | got = require('got'), 5 | readmeToManPage = require('readme-to-man-page'), 6 | npmExpansion = require('npm-expansion'); 7 | 8 | 9 | module.exports = function (name, cb) { 10 | got(registryUrl + name, { json: true }, function (err, pkg) { 11 | if (err) return cb(err); 12 | cb(null, manPage(pkg)); 13 | }); 14 | }; 15 | 16 | 17 | function manPage (pkg) { 18 | return readmeToManPage(pkg.readme, { 19 | name: pkg.name, 20 | version: pkg['dist-tags'].latest, 21 | description: pkg.description, 22 | date: pkg.time && pkg.time.modified, 23 | section: 'npm', 24 | manual: npmExpansion() 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "npm-man", 3 | "version": "0.4.3", 4 | "description": "Open any package readme from npm as a man page", 5 | "author": "Eugene Sharygin ", 6 | "license": "MIT", 7 | "preferGlobal": true, 8 | "bin": { 9 | "npm-man": "cli.js" 10 | }, 11 | "files": [ 12 | "cli.js", 13 | "index.js" 14 | ], 15 | "homepage": "https://github.com/eush77/npm-man", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/eush77/npm-man" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/eush77/npm-man/issues" 22 | }, 23 | "keywords": [ 24 | "api", 25 | "cli", 26 | "docs", 27 | "less", 28 | "man", 29 | "manual", 30 | "more", 31 | "npm", 32 | "pager", 33 | "readme", 34 | "unix", 35 | "viewer" 36 | ], 37 | "dependencies": { 38 | "got": "^5.3.0", 39 | "help-version": "^1.0.0", 40 | "man-pager": "^1.0.0", 41 | "npm-expansion": "^1.0.0", 42 | "readme-to-man-page": "^0.6.0", 43 | "registry-url": "^3.0.3" 44 | }, 45 | "devDependencies": {} 46 | } 47 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eush77/npm-man/1f03b54f4f656058ce51badf467262d855400af5/screenshot.png --------------------------------------------------------------------------------