diff options
author | isaacs <i@izs.me> | 2014-03-19 09:25:40 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2014-03-25 17:42:22 -0700 |
commit | bd547d65983c190eb69ca44d633ea31aca2b7c98 (patch) | |
tree | 01ff3b4e40cb9fc3ed5a42abc4d44cb65d5c7dec /deps/npm/node_modules/read-package-json/read-json.js | |
parent | 7989f42f866699b726f596add387fb19fa39bc55 (diff) | |
download | node-new-bd547d65983c190eb69ca44d633ea31aca2b7c98.tar.gz |
npm: upgrade to 1.4.6
* Documentation upgrades
* Fix glob bug which prevents proper README publishing
* node-gyp upgrade to 0.13
* Documentation updates
* Add --save-exact to save an exact dep (instead of a range)
* alias 't' to 'test'
Diffstat (limited to 'deps/npm/node_modules/read-package-json/read-json.js')
-rw-r--r-- | deps/npm/node_modules/read-package-json/read-json.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/deps/npm/node_modules/read-package-json/read-json.js b/deps/npm/node_modules/read-package-json/read-json.js index 5f69c0dcf6..acb7d62d81 100644 --- a/deps/npm/node_modules/read-package-json/read-json.js +++ b/deps/npm/node_modules/read-package-json/read-json.js @@ -231,17 +231,31 @@ function readme (file, data, cb) { if (data.readme) return cb(null, data); var dir = path.dirname(file) var globOpts = { cwd: dir, nocase: true, mark: true } - glob("README?(.*)", globOpts, function (er, files) { + glob("{README,README.*}", globOpts, function (er, files) { if (er) return cb(er); // don't accept directories. files = files.filter(function (file) { return !file.match(/\/$/) }) if (!files.length) return cb(); - var rm = path.resolve(dir, files[0]) + var fn = preferMarkdownReadme(files) + var rm = path.resolve(dir, fn) readme_(file, data, rm, cb) }) } +function preferMarkdownReadme(files) { + var fallback = 0; + var re = /\.m?a?r?k?d?o?w?n?$/i + for (var i = 0; i < files.length; i++) { + if (files[i].match(re)) + return files[i] + else if (files[i].match(/README$/)) + fallback = i + } + // prefer README.md, followed by README; otherwise, return + // the first filename (which could be README) + return files[fallback]; +} function readme_(file, data, rm, cb) { var rmfn = path.basename(rm); fs.readFile(rm, "utf8", function (er, rm) { |