Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Cooper <mfncooper@gmail.com>2011-10-09 20:13:03 +0400
committerisaacs <i@izs.me>2011-10-13 04:39:08 +0400
commit0c37406165191dbbe984c65ef2719a4c01f1158e (patch)
tree2860c80dd6d1b73e4b834c29148eb4e98e4d3375
parenta496bd001f66e55056670b512d4837a8ca347f29 (diff)
Standardize the 'bugs' field in package.json.
-rw-r--r--doc/cli/json.md17
-rw-r--r--lib/bugs.js6
-rw-r--r--lib/utils/read-json.js14
3 files changed, 32 insertions, 5 deletions
diff --git a/doc/cli/json.md b/doc/cli/json.md
index 068ddf977..5f6e7ef62 100644
--- a/doc/cli/json.md
+++ b/doc/cli/json.md
@@ -96,6 +96,23 @@ been published somewhere else, and spit at you.
Literally. Spit. I'm so not kidding.
+## bugs
+
+The url to your project's issue tracker and / or the email address to which
+issues should be reported. These are helpful for people who encounter issues
+with your package.
+
+It should look like this:
+
+ { "url" : "http://github.com/owner/project/issues"
+ , "email" : "project@hostname.com"
+ }
+
+You can specify either one or both values. If you want to provide only a url,
+you can specify the value for "bugs" as a simple string instead of an object.
+
+If a url is provided, it will be used by the `npm bugs` command.
+
## people fields: author, contributors
The "author" is one person. "contributors" is an array of people. A "person"
diff --git a/lib/bugs.js b/lib/bugs.js
index 39e746592..654f4487b 100644
--- a/lib/bugs.js
+++ b/lib/bugs.js
@@ -24,11 +24,7 @@ function bugs (args, cb) {
, repo = d.repository || d.repositories
if (bugs) {
if (typeof bugs === "string") return open(bugs, cb)
- if (bugs.url) bugs = bugs.url
- else if (bugs.web) bugs = bugs.web
- else if (bugs.name && /^http/.test(bugs.name)) bugs = bugs.name
- else bugs = null
- if (bugs) return open(bugs, cb)
+ if (bugs.url) return open(bugs.url, cb)
}
if (repo) {
if (Array.isArray(repo)) repo = repo.shift()
diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js
index ac978e8cc..d8a195e88 100644
--- a/lib/utils/read-json.js
+++ b/lib/utils/read-json.js
@@ -181,6 +181,20 @@ function typoWarn (json) {
}
})
+ // bugs typos
+ var bugsTypos = { "web": "url"
+ , "name": "url"
+ }
+
+ if (typeof json.bugs === "object") {
+ Object.keys(bugsTypos).forEach(function (d) {
+ if (json.bugs.hasOwnProperty(d)) {
+ log.warn( "package.json: bugs['" + d + "'] should probably be "
+ + "bugs['" + bugsTypos[d] + "']", json._id)
+ }
+ })
+ }
+
// script typos
var scriptTypos = { "server": "start" }
if (json.scripts) Object.keys(scriptTypos).forEach(function (d) {