1 | const fs = require('fs');
|
2 | const path = require('path');
|
3 |
|
4 | module.exports = function findReadme(dir) {
|
5 | const readmeFilenames = [
|
6 | 'README.markdown',
|
7 | 'README.md',
|
8 | 'Readme.md',
|
9 | 'readme.markdown',
|
10 | 'readme.md'
|
11 | ];
|
12 |
|
13 | const readmeFile = fs.readdirSync(dir).find(function(filename) {
|
14 | return readmeFilenames.indexOf(filename) >= 0;
|
15 | });
|
16 |
|
17 | if (readmeFile) {
|
18 | return path.join(fs.realpathSync(dir), readmeFile);
|
19 | }
|
20 |
|
21 | return 'README.md';
|
22 | };
|