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:
authorisaacs <i@izs.me>2011-02-20 02:36:42 +0300
committerisaacs <i@izs.me>2011-02-20 02:36:42 +0300
commit8518923b6527ba82f23d063e94d736760c34973b (patch)
treeb34cfc99c477d8d723e1ae5e751eb58095231190
parent3e90c99827acd65fddbc5ecca5b18fd3e1091aab (diff)
Pass the buck on package.json parse errors.
-rw-r--r--lib/utils/error-handler.js10
-rw-r--r--lib/utils/read-json.js3
-rw-r--r--npm.js1
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/utils/error-handler.js b/lib/utils/error-handler.js
index 0bcdd156a..615008114 100644
--- a/lib/utils/error-handler.js
+++ b/lib/utils/error-handler.js
@@ -62,9 +62,17 @@ function errorHandler (er) {
," "+er.script
,"You can get their info via:"
," npm owner ls "+er.pkgname
- ,"There may be additional logging output above."
+ ,"There is likely additional logging output above."
].join("\n"))
break
+ case npm.EJSONPARSE:
+ log.error(["","Failed to parse package.json data."
+ ,"Note that package.json must be actual JSON, not"
+ ,"just a JavaScript object."
+ ,"","This changed in npm 0.3.0, and is not a bug in npm."
+ ,"Tell the package author to fix their package.json file."
+ ,""].join("\n"), "JSON.parse")
+ break
case npm.E404:
log.error(["","Looks like '"+er.pkgid+"' is not in the npm registry."
,"You should bug the author to publish it."
diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js
index 62bff7f8c..653a591db 100644
--- a/lib/utils/read-json.js
+++ b/lib/utils/read-json.js
@@ -71,7 +71,8 @@ function processJsonString (opts, cb) { return function (er, jsonString) {
json = JSON.parse(jsonString)
} catch (ex) {
var e = new Error(
- "Failed to parse json\n"+ex.message+"\n"+jsonString)
+ "Failed to parse json\n"+ex.message)
+ e.errno = npm.EJSONPARSE
if (cb) return cb(e)
throw e
}
diff --git a/npm.js b/npm.js
index 686a6ab47..32fcd8730 100644
--- a/npm.js
+++ b/npm.js
@@ -26,6 +26,7 @@ npm.commands = {}
npm.ELIFECYCLE = {}
npm.E404 = {}
npm.EPUBLISHCONFLICT = {}
+npm.EJSONPARSE = {}
try {