Skip to content

Commit

Permalink
infer readme name instead of defaulting to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit authored and tmcw committed May 22, 2018
1 parent 2b4612a commit f70961d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -39,6 +39,7 @@
"parse-filepath": "^1.0.2",
"pify": "^3.0.0",
"read-pkg-up": "^3.0.0",
"readme-file": "^0.2.0",
"remark": "^9.0.0",
"remark-html": "7.0.0",
"remark-reference-links": "^4.0.1",
Expand Down
10 changes: 9 additions & 1 deletion src/commands/readme.js
Expand Up @@ -8,10 +8,18 @@ const sharedOptions = require('./shared_options');
const inject = require('mdast-util-inject');
const chalk = require('chalk');
const disparity = require('disparity');
const getReadmeFile = require('readme-file');

module.exports.command = 'readme [input..]';
module.exports.description = 'inject documentation into your README.md';

let DEFAULT_README_FILE = 'README.md';
try {
DEFAULT_README_FILE = getReadmeFile('.');
} catch (err) {
// ignore and use default README.md
}

/**
* Add yargs parsing for the readme command
* @param {Object} yargs module instance
Expand All @@ -25,7 +33,7 @@ module.exports.builder = Object.assign(
{
'readme-file': {
describe: 'The markdown file into which to inject documentation',
default: 'README.md'
default: DEFAULT_README_FILE
},
section: {
alias: 's',
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Expand Up @@ -5173,6 +5173,16 @@ readdirp@^2.0.0:
readable-stream "^2.0.2"
set-immediate-shim "^1.0.1"

readme-file@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/readme-file/-/readme-file-0.2.0.tgz#4ce8f43d756f53740f39b7a9121469d7fb0508fc"
dependencies:
readme-filenames "^1.0.1"

readme-filenames@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/readme-filenames/-/readme-filenames-1.0.1.tgz#9c125c69839c3741edf4f0b4b46ba51e1a3a4bf8"

realpath-native@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.0.0.tgz#7885721a83b43bd5327609f0ddecb2482305fdf0"
Expand Down

0 comments on commit f70961d

Please sign in to comment.