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
path: root/bin
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-04-30 21:55:01 +0400
committerisaacs <i@izs.me>2011-04-30 22:00:00 +0400
commit1287c7fd4481c921881a39ed27fee7965e3b241a (patch)
tree0c41fae6c9fdf33e2aeedcab3da87f89bc7b0084 /bin
parent29d3d59f124467276e0637ca281222aec39e1bec (diff)
Read contributors out of AUTHORS file, if present
Diffstat (limited to 'bin')
-rwxr-xr-xbin/read-package-json.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/read-package-json.js b/bin/read-package-json.js
index 84944df72..8c95d86e8 100755
--- a/bin/read-package-json.js
+++ b/bin/read-package-json.js
@@ -3,16 +3,20 @@ if (argv.length < 3) {
console.error("Usage: read-package.json <file> [<fields> ...]")
process.exit(1)
}
+
var fs = require("fs")
, file = argv[2]
- , data = JSON.parse(fs.readFileSync(file, "utf8"))
+ , readJson = require("../lib/utils/read-json")
-if (argv.length === 3) console.log(data)
-else argv.slice(3).forEach(function (field) {
- field = field.split(".")
- var val = data
- field.forEach(function (f) {
- val = val[f]
+readJson(file, function (er, data) {
+ if (er) throw er
+ if (argv.length === 3) console.log(data)
+ else argv.slice(3).forEach(function (field) {
+ field = field.split(".")
+ var val = data
+ field.forEach(function (f) {
+ val = val[f]
+ })
+ console.log(val)
})
- console.log(val)
})