Skip to content

Commit 0c48198

Browse files
transitive-bullshittmcw
authored andcommitted
move readme-file into its own file
1 parent f70961d commit 0c48198

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
"parse-filepath": "^1.0.2",
4040
"pify": "^3.0.0",
4141
"read-pkg-up": "^3.0.0",
42-
"readme-file": "^0.2.0",
4342
"remark": "^9.0.0",
4443
"remark-html": "7.0.0",
4544
"remark-reference-links": "^4.0.1",

src/commands/readme.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ const sharedOptions = require('./shared_options');
88
const inject = require('mdast-util-inject');
99
const chalk = require('chalk');
1010
const disparity = require('disparity');
11-
const getReadmeFile = require('readme-file');
11+
const getReadmeFile = require('../get-readme-file');
1212

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

16-
let DEFAULT_README_FILE = 'README.md';
16+
let defaultReadmeFile = 'README.md';
1717
try {
18-
DEFAULT_README_FILE = getReadmeFile('.');
18+
defaultReadmeFile = getReadmeFile('.');
1919
} catch (err) {
2020
// ignore and use default README.md
2121
}
@@ -33,7 +33,7 @@ module.exports.builder = Object.assign(
3333
{
3434
'readme-file': {
3535
describe: 'The markdown file into which to inject documentation',
36-
default: DEFAULT_README_FILE
36+
default: defaultReadmeFile
3737
},
3838
section: {
3939
alias: 's',

src/get-readme-file.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* @flow */
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
module.exports = function findReadme(dir: string) {
7+
const readmeFilenames = [
8+
'README',
9+
'README.markdown',
10+
'README.md',
11+
'README.txt',
12+
'Readme.md',
13+
'readme.markdown',
14+
'readme.md',
15+
'readme.txt'
16+
];
17+
18+
const readmeFile = fs.readdirSync(dir).find(function(filename) {
19+
return readmeFilenames.indexOf(filename) >= 0;
20+
});
21+
22+
if (readmeFile) {
23+
return path.join(fs.realpathSync(dir), readmeFile);
24+
}
25+
};

yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5173,16 +5173,6 @@ readdirp@^2.0.0:
51735173
readable-stream "^2.0.2"
51745174
set-immediate-shim "^1.0.1"
51755175

5176-
readme-file@^0.2.0:
5177-
version "0.2.0"
5178-
resolved "https://registry.yarnpkg.com/readme-file/-/readme-file-0.2.0.tgz#4ce8f43d756f53740f39b7a9121469d7fb0508fc"
5179-
dependencies:
5180-
readme-filenames "^1.0.1"
5181-
5182-
readme-filenames@^1.0.1:
5183-
version "1.0.1"
5184-
resolved "https://registry.yarnpkg.com/readme-filenames/-/readme-filenames-1.0.1.tgz#9c125c69839c3741edf4f0b4b46ba51e1a3a4bf8"
5185-
51865176
realpath-native@^1.0.0:
51875177
version "1.0.0"
51885178
resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.0.0.tgz#7885721a83b43bd5327609f0ddecb2482305fdf0"

0 commit comments

Comments
 (0)