Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var msee = require('msee');
var fs = require('fs');
var path = require('path');
var colors = require('ansicolors');
var divider = '\n' + colors.bgMagenta(colors.brightYellow('-- README --')) + '\n';
function pair (names, exts) {
return names.reduce(function (acc, name) {
return acc.concat(exts.map(function (ext) { return name + ext; }));
}, []);
}
function getReadmePath (packagedir) {
var tries = pair([ 'readme', 'README', 'Readme', 'ReadMe' ], [ '.md', '.markdown', '.MARKDOWN', '.MD' ]);
var match;
tries.some(function (x) {
var p = path.join(packagedir, x);
if (fs.existsSync(p)) return match = p, match;
});
return match;